-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
request disconnect event does not trigger for certain HTTP methods under node v16 #4315
Comments
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. |
Edit: I misread your code. A |
Hmm, this could be a node bug. It seems that It seems node wants to deprecate Working on a patch that works around this issue by not relying on the |
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: nodejs/node#40775. |
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. |
https://eaflood.atlassian.net/browse/WATER-4039 Phew! Somehow when looking into why there were errors during an import process we've ended up needing to upgrade Hapi! In order to better debug issues with the NALD import process we wanted to add a new POST endpoint that would allow us to trigger it manually. But when we did we saw the request logged but nothing was actually firing. The handler would not be called and the request would not disconnect leaving Postman whirring away. We quickly spotted `GET` requests were fine it was just `POST` failing. Hmm 🤔 Some Googling later and we found we were not alone - [POST request not completing on postman](https://stackoverflow.com/a/72642389/6117745) - [Hapi js server does not respond to my post route](https://www.reddit.com/r/node/comments/syq6t0/hapi_js_server_does_not_respond_to_my_post_route/?utm_source=share&utm_medium=web2x&context=3) - [https://github.com/hapijs/hapi/issues/4315](request disconnect event does not trigger for certain HTTP methods under node v16) It seems the root cause is running Hapi on Node v16 which we are doing in our local dev environment. In our AWS environments we're running v14 but we intend to upgrade as soon as SROC supplementary billing is shipped. So, we know this project is fine in AWS running v14 which concurs with those posts. But we also know apps like [water-abstraction-service](https://github.com/DEFRA/water-abstraction-service) are handling `POST` requests fine in our local dev environment. The difference is the version of Hapi; they are running v21 but the import service is running v18. This change updates Hapi to v21 (and anything else needed along the way) in order to resolve this issue and get the project ready for upgrading all our environments to v16.
https://eaflood.atlassian.net/browse/WATER-4039 Phew! Somehow when looking into why there were errors during an import process we've ended up needing to upgrade Hapi! In order to better debug issues with the NALD import process we wanted to add a new POST endpoint that would allow us to trigger it manually. But when we did we saw the request logged but nothing was actually firing. The handler would not be called and the request would not disconnect leaving Postman whirring away. We quickly spotted `GET` requests were fine it was just `POST` failing. Hmm 🤔 Some Googling later and we found we were not alone - [POST request not completing on postman](https://stackoverflow.com/a/72642389/6117745) - [Hapi js server does not respond to my post route](https://www.reddit.com/r/node/comments/syq6t0/hapi_js_server_does_not_respond_to_my_post_route/?utm_source=share&utm_medium=web2x&context=3) - [request disconnect event does not trigger for certain HTTP methods under node v16](hapijs/hapi#4315) It seems the root cause is running Hapi on Node v16 which we are doing in our local dev environment. In our AWS environments, we're running v14 but we intend to upgrade as soon as SROC supplementary billing is shipped. So, we know this project is fine in AWS running v14 which concurs with those posts. But we also know apps like [water-abstraction-service](https://github.com/DEFRA/water-abstraction-service) are handling `POST` requests fine in our local dev environment. The difference is the version of Hapi; they are running v21 but the import service is running v18. This change updates Hapi to v21 (and anything else needed along the way) in order to resolve this issue and get the project ready for upgrading all our environments to v16. The upgrade from version 18->19 introduces a breaking change as per the v19 release notes hapijs/hapi#4017 - _"No joi schema compiler is loaded by default and must be explicitly loaded"_. This breaking change produces the error `error: AssertError: Cannot set uncompiled validation rules without configuring a validator` which is fixed by explicitly loading joi. **Notes** - Bump `@hapi/hapi` 3 major versions - Fix issues caused by updating `@hapi/hapi` (The upgrade from version 18->19 introduces a breaking change "No joi schema compiler is loaded by default and must be explicitly loaded". This commit fixes that issue as per the v19 release notes: hapijs/hapi#4017) --------- Co-authored-by: Jason Claxton <[email protected]> Co-authored-by: Jason Claxton <[email protected]>
In my local testing, an aborted POST results in Hapi logging a If so, then would it help to update lib/request.js's internals.event to emit a (I could easily be missing or misunderstanding something here - I'm unclear on the difference between |
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.
The text was updated successfully, but these errors were encountered: