Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPIPE errors from aborted request #4296

Open
joshkel opened this issue Oct 5, 2021 · 7 comments
Open

EPIPE errors from aborted request #4296

joshkel opened this issue Oct 5, 2021 · 7 comments
Labels
bug Bug or defect

Comments

@joshkel
Copy link
Contributor

joshkel commented Oct 5, 2021

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: 14.18.0
  • module version with issue: 20.1.5
  • last module version without issue: unknown
  • environment (e.g. node, browser, native): Node
  • used with (e.g. hapi application, another framework, standalone, ...): hapi application
  • any other relevant information: N/A

What are you trying to achieve or the steps to reproduce?

Our Sentry setup has caught and logged the following error several times:

Error: write EPIPE
  File "internal/stream_base_commons.js", line 156, col 25, in afterWriteDispatched
  File "internal/stream_base_commons.js", line 147, col 3, in writeGeneric
  File "net.js", line 787, col 11, in Socket._writeGeneric
  File "net.js", line 799, col 8, in Socket._write
  File "internal/streams/writable.js", line 358, col 12, in writeOrBuffer
  File "internal/streams/writable.js", line 303, col 10, in Socket.Writable.write
  File "_http_outgoing.js", line 351, col 17, in ServerResponse._writeRaw
  File "_http_outgoing.js", line 327, col 15, in ServerResponse._send
  File "_http_outgoing.js", line 846, col 10, in ServerResponse.end
  File "/home/app/deploy/node_modules/@hapi/hapi/lib/transmit.js", line 318, col 21, in internals.end
    request.raw.res.end();                                          // Triggers injection promise resolve

This apparently happens when the client aborts its request; it's preceded by ["request","error","abort"] and ["response","error","aborted"] error messages.

We've gotten several errors like this, although I haven't yet tried to reproduce it locally or on demand.

What was the result you got?

An EPIPE error from an apparently uncaught exception.

What result did you expect?

No additional errors logged other than the abort message.

@joshkel joshkel added the support Questions, discussions, and general support label Oct 5, 2021
@devinivy devinivy added bug Bug or defect and removed support Questions, discussions, and general support labels Oct 6, 2021
@devinivy
Copy link
Member

devinivy commented Oct 6, 2021

Thanks for the report! Very timely— if you're interested you can check-out progress on a similar (or potentially the same?) issue in #4295.

@kanongil
Copy link
Contributor

kanongil commented Oct 6, 2021

Hmm, we already test for errors during stream transmission, but not combined with a client abort. Guess we need another test case.

@kanongil
Copy link
Contributor

kanongil commented Oct 6, 2021

Actually, this does not make sense.

The internals.end() method is called to handle the request 'aborted' event and then proceeds to call res.end().

Response will have the res.finished === false, so it will try to send a trailer to the shared socket.

Once it calls res._writeRaw(), it should just immediately return false, since the socket should have been destroyed.

This means that it should never even try to write. Unless maybe you have set the hidden server.httpAllowHalfOpen property to true?

@mhassan1
Copy link

mhassan1 commented Oct 27, 2021

maybe related? nodejs/node#40553

can you try node 14.17 instead of node 14.18?

@aaestrada
Copy link

aaestrada commented Oct 29, 2021

Hi Folks! I'm upgrade my app to node 14 and @hapi/hapi: 20.0.0 and i'm getting

"message": "write EPIPE", "stack": Error: write EPIPE at afterWriteDispatched

this happen using node V14.18.1 orV14.15.5

@kanongil
Copy link
Contributor

@aaestrada If you can reliably reproduce the issue, please file an issue.

@kanongil
Copy link
Contributor

Regardless of what triggers this, hapi should probably handle thrown errors when calling request.raw.res.end().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug or defect
Projects
None yet
Development

No branches or pull requests

5 participants