Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ function connectionListener(socket) {
}

function onParserExecute(ret, d) {
socket._unrefTimer();
debug('SERVER socketOnParserExecute %d', ret);
onParserExecuteCommon(ret, undefined);
}
Expand Down
36 changes: 36 additions & 0 deletions test/parallel/test-http-server-consumed-timeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const http = require('http');

const server = http.createServer((req, res) => {
server.close();

res.writeHead(200);
res.flushHeaders();

req.setTimeout(200, () => {
assert(false, 'Should not happen');
});
req.resume();
req.once('end', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: wrap this in common.mustCall() ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

res.end();
});
});

server.listen(common.PORT, () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common.mustCall() here too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

const req = http.request({
port: common.PORT,
method: 'POST'
}, (res) => {
const interval = setInterval(() => {
req.write('a');
}, 25);
setTimeout(() => {
clearInterval(interval);
req.end();
}, 400);
Copy link
Contributor

@mscdex mscdex Apr 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This timeout value should probably be wrapped with common.platformTimeout()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

});
req.write('.');
});