Skip to content

fix: prevent writing after response headers are sent - #163

Open
hata6502 wants to merge 2 commits into
pillarjs:masterfrom
hata6502:fix/headers-sent-after-request-finish
Open

hata6502 wants to merge 2 commits into
pillarjs:masterfrom
hata6502:fix/headers-sent-after-request-finish

Conversation

@hata6502

Copy link
Copy Markdown

Fixes #162

Changes

Check res.headersSent at the beginning of the write() callback invoked by onFinished.

If the response headers have already been sent, stop without writing to the response. This prevents finalhandler from modifying a response sent by another operation and avoids ERR_HTTP_HEADERS_SENT.

The existing behavior of reading the complete request body remains unchanged.

@hata6502

Copy link
Copy Markdown
Author

Hi! Just a gentle ping on this PR.

Would you mind taking a look when you have a chance? I'm happy to make any changes if needed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ERR_HTTP_HEADERS_SENT when headers are sent while finalhandler waits for the request to finish

1 participant