Skip to content

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

Description

@bole1
  • 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

Activity

  1. added
    httpIssues and PRs related to the http subsystem.
    on Jun 5, 2020
  2. bnoordhuis commented on Jun 5, 2020

    @bnoordhuis
    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?

  3. bole1 commented on Jun 5, 2020

    @bole1
    Author

    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

  4. lpinca commented on Aug 20, 2020

    @lpinca
    Member

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

  5. added a commit that references this issue on Sep 9, 2020
  6. added a commit that references this issue on Oct 7, 2020
  7. added a commit that references this issue on Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.httpIssues and PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions