-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Error [ERR_INTERNAL_ASSERTION] on ServerResponse #34229
Comments
Can you check with the latest v12.x, v12.18.2? There have been quite a few http fixes since v12.12.0. |
@bnoordhuis The issue persists even on v12.18.2 |
Can you post the stack trace you get with v12.18.2? (Verbatim, please.) |
`
` |
After I comment
it print new message, which I think it maybe helpful. Node version: v15.0.0-pre
|
The offending line is here: Line 223 in 412c618
And that condition should be logically impossible unless ServerResponse#detachSocket() is called twice somehow.
I had a quick look through your app but it's a bit too big for me to get a good mental picture of how everything slots together. In light of @KuthorX's comment, my guess is that express or nestjs tries to send a second response when the first one has already been sent. The ERR_INTERNAL_ASSERTION exception that node throws isn't helpful and should be fixed but the root cause is probably not a node issue. |
I changed the way how Status response is handled directly in the controller on nestjs. We can close this since it has been resolved as issue on manipulating headers on repsonse object :) |
@bnoordhuis A solution may be adding a flag named function resOnFinish(req, res, socket, state, server) {
if (!!res.finished) {
return;
}
// Usually the first incoming element should be our request. it may
// be that in the case abortIncoming() was called that the incoming
// array will be empty.
assert(state.incoming.length === 0 || state.incoming[0] === req);
state.incoming.shift();
// If the user never called req.read(), and didn't pipe() or
// .resume() or .on('data'), then we call req._dump() so that the
// bytes will be pulled off the wire.
if (!req._consuming && !req._readableState.resumeScheduled)
req._dump();
res.detachSocket(socket);
clearIncoming(req);
process.nextTick(emitCloseNT, res);
if (res._last) {
if (typeof socket.destroySoon === 'function') {
socket.destroySoon();
} else {
socket.end();
}
res.finished = true;
} else if (state.outgoing.length === 0) {
if (server.keepAliveTimeout && typeof socket.setTimeout === 'function') {
socket.setTimeout(server.keepAliveTimeout);
state.keepAliveTimeoutSet = true;
}
} else {
// Start sending the next message
const m = state.outgoing.shift();
if (m) {
m.assignSocket(socket);
}
}
} |
Closing this issue because v12.x goes EOL at the end of this month and no more releases are planned. |
What steps will reproduce the bug?
localhost:3333/api/auth/register
{ "email": "[email protected]", "password": "aaaaa", "firstName": "Test", "lastName": "User" }
How often does it reproduce? Is there a required condition?
Right after the first request. I tried going commit back (which im sure worked just fine), but the error persisted, therefore I think its not related to the code itself.
What is the expected behavior?
User gets registered without node crashing
What do you see instead?
User gets registered, however node crashes with stacktrace:
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
The text was updated successfully, but these errors were encountered: