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:
parent
3770ab99a8
commit
3c83f93437
@ -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();
|
||||
}
|
||||
}
|
||||
|
24
test/parallel/test-http-server-delete-parser.js
Normal file
24
test/parallel/test-http-server-delete-parser.js
Normal 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();
|
Loading…
Reference in New Issue
Block a user