Skip to content

v15.x regression - ERR_INTERNAL_ASSERTION - failed assert(socket._httpMessage === this); #35833

Closed
@kaizhu256

Description

@kaizhu256
  • Version: 15.0.0, 15.0.1
  • Platform: linux, windows
  • Subsystem: x64

What steps will reproduce the bug?

  1. install any node v15.0.x on windows or linux

  2. copy-paste the following in shell (or git-bash for windows):

#!/bin/sh
node -e '
/*jslint node*/
"use strict";
require("http").createServer(function (ignore, res) {
    res.on("error", function () {
        return;
    });
    res.end("cc");
    res.end("dd");
}).listen(8081, function () {
    require("http").request("http://localhost:8081").end();
});
'

# stderr
#
# node:internal/assert:14
#     throw new ERR_INTERNAL_ASSERTION(message);
#     ^
#
# Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
# Please open an issue with this stack trace at https://github.com/nodejs/node/issues
#
#     at new NodeError (node:internal/errors:258:15)
#     at assert (node:internal/assert:14:11)
#     at ServerResponse.detachSocket (node:_http_server:239:3)
#     at resOnFinish (node:_http_server:799:7)
#     at ServerResponse.emit (node:events:327:20)
#     at onFinish (node:_http_outgoing:794:10)
#     at afterWrite (node:internal/streams/writable:496:5)
#     at afterWriteTick (node:internal/streams/writable:483:10)
#     at processTicksAndRejections (node:internal/process/task_queues:79:21) {
#   code: 'ERR_INTERNAL_ASSERTION'
# }

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

  • reproducible everytime.
  • conditions:
  1. ServerResponse must have listener on error event
  2. ServerResponse.prototype.end(...) must be called more than once with non-empty payload

What is the expected behavior?

there should be no ERR_INTERNAL_ASSERTION raised

What do you see instead?

ERR_INTERNAL_ASSERTION raised

Additional information

ERR_INTERNAL_ASSERTION raised at https://github.com/nodejs/node/blob/v15.0.1/lib/_http_server.js#L239

ServerResponse.prototype.detachSocket = function detachSocket(socket) {
  assert(socket._httpMessage === this); // failed assertion
  socket.removeListener('close', onServerResponseClose);
  socket._httpMessage = null;
  this.socket = null;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    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