Skip to content
Permalink
Browse files

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 <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information...
mcollina authored and BethGriggs committed Mar 2, 2019
1 parent 5682e50 commit 1a5dc6a3e7b40376e4360787daf6da472f976238
Showing with 25 additions and 1 deletion.
  1. +1 −1 lib/_http_server.js
  2. +24 −0 test/parallel/test-http-server-delete-parser.js
@@ -724,7 +724,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();
}
}
@@ -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();

0 comments on commit 1a5dc6a

Please sign in to comment.
You can’t perform that action at this time.