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

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

Closed
kaizhu256 opened this issue Oct 27, 2020 · 2 comments
Labels
http Issues or PRs related to the http subsystem.

Comments

@kaizhu256
Copy link
Contributor

kaizhu256 commented Oct 27, 2020

  • 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;
};
@kaizhu256 kaizhu256 changed the title ERR_INTERNAL_ASSERTION - failed assert(socket._httpMessage === this); v15.x regression - ERR_INTERNAL_ASSERTION - failed assert(socket._httpMessage === this); Oct 27, 2020
@Flarna
Copy link
Member

Flarna commented Oct 27, 2020

@ronag I think this is caused by #31818

@rickyes rickyes added the http Issues or PRs related to the http subsystem. label Oct 28, 2020
@rickyes
Copy link
Contributor

rickyes commented Oct 28, 2020

Since after calling .end again with the payload, it did not return in time, causing .onFinish to be called again to trigger the assertion failure, i will fix it.

codebytere pushed a commit that referenced this issue Nov 22, 2020
PR-URL: #35845
Fixes: #35833
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants