-
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
Crashes upon request on Node.js v15.5.0 #4208
Comments
Upon further inspection, I find that the server only crashes on Node.js v15.5.0 and perfectly on Node.js v15.4.0. Here is some additional information useful for more investigation on the issue 👇 Operating System: macOS Big Sur v11.1 |
I can confirm that the hapi test suite fails on node v15.5.0 (also on Linux), with similar issues. The only change that seems relevant, is the refactor in: nodejs/node#33035. |
@kanongil beat me to it 😄. It's really annoying that all of these |
I really didn't believe it initially, but then the only change I made was to update to node v15.5.0, so a quick roll back of node revealed the issue. |
Thanks to Gil's correspondence on nodejs/node#33035 helping to illustrate the issue, this change in node is being reverted: nodejs/node#36647. I will try to keep an eye out for if node tries to re-land the original |
Hi Folks, it would be great if Hapi to get into https://github.com/nodejs/citgm so that we can automatically spot regressions. (FWIW this change is likely to make it in v16) |
@mcollina You should probably address your concerns towards the CITGM project instead given that there is a 5 year old open issue (nodejs/citgm#8) and a PR (nodejs/citgm#436). |
Having encountered this issue, and looked into its cause, I think you might want to re-consider flagging this as a bug. The problem occurs on This Because In my humble opinion, request.js's if (!request) {
return;
}
// autoDestroy is enabled on the `req` stream, and the `req` stream was drained, this is basically the same as the "end" event
// maybe request.raw.req._readableState.ended should be used instead?
if (event === 'close' &&
!request._isPayloadPending) {
return;
}
request._isPayloadPending = false; |
@matthieusieben thanks for taking a close look, I see what you mean. Do you expect that this case can be triggered on node v12/v14? If there's a way to reproduce a bug then I will open a new issue for it, since this issue is now effectively tracking whether node v15 is patched. Either way I will spend some time with the info you provided above, and re-trace your steps in debugging. |
This is fundamentally a node issue. Given that hey have decided to release v15.5.1 with security fixes, without reverting the behavior, puts us in an awkward situation where there is no node v15 versions that are safe to use with hapi. This is somewhat OK, since I believe the official stance that only LTS releases are considered supported. That being said, it is simple to fix in hapi in a way that will work with all node versions. All that is required, is to change the |
I know it's ugly but how about doing this ? if (process.version.startsWith('v15.')) {
this.raw.res.on('close', internals.event.bind(this.raw.res, this._eventContext, 'close'));
} else {
this.raw.req.on('close', internals.event.bind(this.raw.req, this._eventContext, 'close'));
} |
The security releases where planned and prepared before this issue was opened. Unfortunately there was no window of opportunity to ship a v15 release before the security fixes due to the xmas break (and we couldn't delay the security releases, in case you are wondering). Note that the revert in v15 has already landed and it will be part of the next v15 release: nodejs/node#36647. The original change will still be present in v16 as it's deemed correct. This leaves probably some time for you to figure how to fix it on the Hapi side. |
Thank you @mcollina 👍 It's especially useful to know that in v16 the original change will be present. For those following along: I will open a separate issue to address this. It sounds like we already have a pretty good understanding of what needs to be done through all the investigation that has been done for this issue. |
I don't expect that there is a need to special case this. Using |
Due to the following bug in v15 hapijs/hapi#4208
This commit updates the response logic to emit the 'close' event if the request is closed. Refs: hapijs/hapi#4208
Node 15.6.x was released with the fix for hapijs/hapi#4208 so re-enable testing in CI.
Node 15.6.x was released with the fix for hapijs/hapi#4208 so re-enable testing in CI.
I think we can close this one out :) Node v15.6.0 reverted the change, shot now supports the res close event in hapijs/shot#139, and there's a PR to future-proof hapi for node v16 in #4225. |
Support plan
Context
What are you trying to achieve or the steps to reproduce?
Trying to start a Hapi.js server on
node v15.5.0
, using the following code from official docs 👇What was the result you got?
When a request is sent, the server crashes with the following message 👇
What result did you expect?
The server to function normally and respond to requsets.
The text was updated successfully, but these errors were encountered: