Skip to content

Handle thrown error from res.setHeader() and res.writeHead()#3178

Merged
hueniverse merged 2 commits into
hapijs:masterfrom
kanongil:catch-errors-fix
Jul 5, 2016
Merged

Handle thrown error from res.setHeader() and res.writeHead()#3178
hueniverse merged 2 commits into
hapijs:masterfrom
kanongil:catch-errors-fix

Conversation

@kanongil
Copy link
Copy Markdown
Contributor

The behavior of res.writeHead() is changed in Node@6 (and possibly node@4.4.5) so that it can throw a RangeError for certain statusCodes, see nodejs/node#6291. When this throws, hapi will log an internal error without sending a response.

This PR adds a try/catch to catch this error and respond with a 500 to the client instead.

Additionally, it will catch thrown errors from res.setHeader(), eg. for an empty string header, and respond as above.

@hueniverse hueniverse added the bug Bug or defect label May 24, 2016
@hueniverse hueniverse self-assigned this May 24, 2016
@stanislav-polishchuk
Copy link
Copy Markdown

Hi, @hueniverse any updates when this pull request will be merged?

@hueniverse
Copy link
Copy Markdown
Contributor

Probably another week or so.

@hueniverse hueniverse added this to the 13.5.0 milestone Jul 5, 2016
@hueniverse hueniverse merged commit 25db02a into hapijs:master Jul 5, 2016
hueniverse added a commit that referenced this pull request Jul 6, 2016
@lock
Copy link
Copy Markdown

lock Bot commented Jan 9, 2020

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.

@lock lock Bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Bug or defect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants