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

fix: prevent writing after response headers are sent#163
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.

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