Open FaHeymann opened 2 years ago
Thanks for the report. Node v16 has a change that causes issues for requests with payloads. We have worked to support it fully, but it seems that it is still causing trouble.
Looking at the docs, hapi does not guarantee that 'disconnect'
is called. In fact the v15 behaviour could be considered a bug:
'disconnect' - emitted when a request errors or aborts unexpectedly.
Maybe you are using the event for something that it is not intended to handle?
Edit: I misread your code. A 'disconnect'
event should definitely happen.
Hmm, this could be a node bug. It seems that http.IncomingMessage
no longer emits 'aborted'
events once the payload has been delivered. It also seems that node will now deliver 'error'
emits (with Error: aborted
) after the 'close'
event!
It seems node wants to deprecate 'aborted'
.
Working on a patch that works around this issue by not relying on the 'aborted'
event (or property).
There does not appear to be a non-hacky way to work around this issue with node v16+. I have reported the underlying issue here: https://github.com/nodejs/node/issues/40775.
It also seems that node will now deliver 'error' emits (with Error: aborted) after the 'close' event!
Do you have a repro for that? It shouldn't happen.
It also seems that node will now deliver 'error' emits (with Error: aborted) after the 'close' event!
Do you have a repro for that? It shouldn't happen.
I don't think it actually does. I likely misread the initial testing I was doing.
In my local testing, an aborted POST results in Hapi logging a request
error
close
event, so it seems that it is detecting the disconnect at some level?
If so, then would it help to update lib/request.js's internals.event to emit a disconnect
event on close
as well as abort
?
(I could easily be missing or misunderstanding something here - I'm unclear on the difference between request
error
close
and request
error
abort
.)
Support plan
Context
What are you trying to achieve or the steps to reproduce?
It seems like the
disconnect
event of requests does only fire for GET requests but not for other HTTP methods starting from nodeJS v16. See also the test script below. With node v15 it fires for all of them. In both versions thefinish
event also seems to not trigger for GET. I don't know why there are differences in the bahaviour between http methods in the first place.What was the result you got?
Node 16:
Node 15:
What result did you expect?
I expected the disconnect event to fire in all cases.