Skip to content

Commit cb88c58

Browse files
mcollinaBethGriggs
authored andcommitted
http: check for existance in resetHeadersTimeoutOnReqEnd
socket.parser can be undefined under unknown circumstances. This is a fix for a bug I cannot reproduce but it is affecting people. Fixes: #26366 PR-URL: #26402 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 9f5ad9b commit cb88c58

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/_http_server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ function resetHeadersTimeoutOnReqEnd() {
741741
const parser = this.socket.parser;
742742
// Parser can be null if the socket was destroyed
743743
// in that case, there is nothing to do.
744-
if (parser !== null) {
744+
if (parser) {
745745
parser.parsingHeadersStart = nowDate();
746746
}
747747
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
const http = require('http');
6+
7+
const server = http.createServer(common.mustCall((req, res) => {
8+
res.writeHead(200, { 'Content-Type': 'text/plain' });
9+
res.write('okay', common.mustCall(() => {
10+
delete res.socket.parser;
11+
}));
12+
res.end();
13+
}));
14+
15+
server.listen(1337, '127.0.0.1');
16+
server.unref();
17+
18+
const req = http.request({
19+
port: 1337,
20+
host: '127.0.0.1',
21+
method: 'GET',
22+
});
23+
24+
req.end();

0 commit comments

Comments
 (0)