-
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
"Cannot set headers after they are sent to the client" after returning h.abandon #3884
Comments
Encountering the same problem with hapi version 17.8.1, with the exact use case. Based on further investigation, it seems like |
I found a hacky workaround for this problem.
Setting |
@hueniverse thanks for the fix. will there be a 17 release with this fix? |
v17 will be updated at some point in the next couple of months. I'm running on extremely limited resources right now and v18 is my priority. If you need it sooner, a PR backporting the fix to v17 would speed things up. |
Handle signals in onRequest. Closes #3884
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
Are you sure this is an issue with the hapi core module or are you just looking for some help?
Base on my understanding of the doc on
h.abandon
and the behavior I am able to repro, I believe so.Is this a security related issue?
No
What are you trying to achieve or the steps to reproduce?
I encountered this issue while trying to use webpack-hot-middleware.
webpack-hot-middleware uses EventStream and established a keep alive connection on the
request.raw.res
object. In that case, it has taken over the request lifecycle. Instead of leaving Hapi hanging with an unresolved promise, I'd like to returnh.abandon
.According to https://hapijs.com/api#h.abandon:
I interpret that as Hapi would not try to do anything with response.
However, I get the following error after returning
h.abandon
:I was able to repro the same behavior with this simple sample:
What was the result you received?
What did you expect?
Hapi abandoning the request lifecycle and response and not attempt to set header on the response object.
Context
node version:
10.13.0
hapi version:
17.7.0
os: MacOS High Sierra 10.13.6
any other relevant information:
The text was updated successfully, but these errors were encountered: