Skip to content

Commit f68e454

Browse files
committed
Make sure headers are not set twice on error
1 parent 72b6b07 commit f68e454

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/core/status-handlers.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ exports['416'] = (res, next) => {
5454
// flagrant error
5555
exports['500'] = (res, next, opts) => {
5656
res.statusCode = 500;
57-
res.setHeader('content-type', 'text/html');
57+
try {
58+
res.setHeader('content-type', 'text/html');
59+
} catch (e) {
60+
// errors may have triggered headers being sent already, make sure we don't hide the underlying error
61+
}
5862
const error = String(opts.error.stack || opts.error || 'No specified error');
5963
const html = `${[
6064
'<!doctype html>',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
],
3030
"man": "./doc/http-server.1",
3131
"engines": {
32-
"node": ">=12"
32+
"node": ">=12.16"
3333
},
3434
"contributors": [
3535
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy