Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http.IncomingMessage doesn't fire callback on 'timeout' #33734

Closed
bole1 opened this issue Jun 5, 2020 · 3 comments
Closed

http.IncomingMessage doesn't fire callback on 'timeout' #33734

bole1 opened this issue Jun 5, 2020 · 3 comments
Labels
confirmed-bug Issues with confirmed bugs. http Issues or PRs related to the http subsystem.

Comments

@bole1
Copy link

bole1 commented Jun 5, 2020

  • Version:14.3.0
  • Platform:
  • Subsystem:

What steps will reproduce the bug?

Source code from lib/_http_incoming.js:

IncomingMessage.prototype.setTimeout = function setTimeout(msecs, callback) {
  if (callback)
    this.on('timeout', callback);
  this.socket.setTimeout(msecs);
  return this;
};

IncomingMessage doesn't emit 'timeout' so callback will never be fired

How often does it reproduce? Is there a required condition?

What is the expected behavior?

IncomingMessage.prototype.setTimeout = function setTimeout(msecs, callback) {
   this.socket.setTimeout(msecs,callback);
  return this;
};

EDIT(trivikr): put code in a code block

@bnoordhuis bnoordhuis added the http Issues or PRs related to the http subsystem. label Jun 5, 2020
@bnoordhuis
Copy link
Member

That doesn't sound right. lib/_http_client.js and lib/_http_server.js install 'timeout' listeners on the socket object that forward to the request object (in the case of lib/_http_client.js) or the request, response and server object.

Can you post a test case (no third-party dependencies) that demonstrates the issue you're seeing?

@bole1
Copy link
Author

bole1 commented Jun 5, 2020

Test case:

server.js:

const http = require('http');
const hostname = 'localhost';
const port = 8080;
const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.flushHeaders();
});
server.listen(port, hostname);

client.js:

const http = require('http');
const host = 'localhost';
const port = 8080;
http.get({host: host, port: port}, (res) => {
  res.setTimeout(1000, () => console.log('timeout from IncomingMessage'));//not fired
  res.socket.setTimeout(1000, () => console.log('timeout from socket')); //fired
});

EDIT(trivikr): put code in code block

bnoordhuis added a commit to bnoordhuis/io.js that referenced this issue Jun 13, 2020
@lpinca lpinca added the confirmed-bug Issues with confirmed bugs. label Aug 20, 2020
@lpinca
Copy link
Member

lpinca commented Aug 20, 2020

@bnoordhuis is the fix above not ready or did you forget to open a PR with it?

juanarbol pushed a commit to juanarbol/node that referenced this issue Sep 9, 2020
BethGriggs pushed a commit that referenced this issue Oct 13, 2020
Fixes: #33734

PR-URL: #34913
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Ricky Zhou <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
joesepi pushed a commit to joesepi/node that referenced this issue Jan 8, 2021
Fixes: nodejs#33734

PR-URL: nodejs#34913
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Ricky Zhou <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants