0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

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: https://github.com/nodejs/node/issues/26366

PR-URL: https://github.com/nodejs/node/pull/26402
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Matteo Collina 2019-03-02 19:09:44 +01:00
parent 3770ab99a8
commit 3c83f93437
2 changed files with 25 additions and 1 deletions

View File

@ -755,7 +755,7 @@ function resetHeadersTimeoutOnReqEnd() {
const parser = this.socket.parser;
// Parser can be null if the socket was destroyed
// in that case, there is nothing to do.
if (parser !== null) {
if (parser) {
parser.parsingHeadersStart = nowDate();
}
}

View File

@ -0,0 +1,24 @@
'use strict';
const common = require('../common');
const http = require('http');
const server = http.createServer(common.mustCall((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('okay', common.mustCall(() => {
delete res.socket.parser;
}));
res.end();
}));
server.listen(1337, '127.0.0.1');
server.unref();
const req = http.request({
port: 1337,
host: '127.0.0.1',
method: 'GET',
});
req.end();