Skip to content

Undocumented breaking change on v16.0.0 #38924

@mmarchini

Description

@mmarchini
  • Version: v16.0.0
  • Platform: OS X
  • Subsystem: http

What steps will reproduce the bug?

  1. Save the script below as index.js and run it.
'use strict'
const http = require('http');

const requestListener = function (req, res) {
  req.on('data', () => {});

  req.once('end', () => {
    console.log(1);
  });

  req.once('close', () => {
    console.log(2);
  });
}

const server = http.createServer(requestListener);
server.listen(8080);
  1. Run curl localhost:8080

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

Always

What is the expected behavior?

Prior to v16, the server would print the output below and hang.

$ node index.js
1

What do you see instead?

On v16, the server prints the output below and hang.

$ node index.js
1
2

On both cases curl doesn't exit while waiting for a response. Note that 2 is being called because close is being emitted even though the connection is not closed yet. I'm not sure if that is intended behavior or not, but I couldn't find anything in the changelog suggesting this was an intentional change. Furthermore, it's a breaking change and it should be documented as such.

Additional information

The example above is an overly simplification of a situation I've stumbled upon while investigating failing restify tests on Node.js v16. The failing test in question is this, and the failure happens because restify expects close to only be called when the connection closes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.httpIssues or 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