-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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] #48358
Comments
Please post a test case that does not use third-party dependencies like ws. As the error message says, it's likely incorrect usage of node.js internals. I'll reopen this when you've updated the test case. |
Sure, no problem. const { Agent, request } = require("http")
const { createConnection } = require("net");
const agent = new Agent({
maxSockets: 1,
keepAlive: true
});
agent.createConnection = (options) => {
let { host, port } = options;
console.log("Create connection", host, port);
let socket = createConnection(options);
return new Proxy(socket, {
// proxy handler here
});
};
let req = request("http://example.com", {
agent
});
req.on("response", (res) => {
res.pipe(process.stdout);
});
req.end(); Output:
As said above, without the proxied socket, everything works fine. |
It's not surprising it doesn't work because the proxy breaks object equivalence:
That becomes relevant when I don't consider that a bug because you're breaking a rather fundamental assumption. Node is right to complain about "incorrect usage of Node.js internals." :-) |
Hmm, thats not good for me 😞 I try to better understand the anatomy of a http request and the job of the agent in this context. Is there somewhere a diagram of the workflow of the agent? |
The documentation for |
Version
v16.20.0
Platform
Linux stirner 5.4.0-149-generic #166~18.04.1-Ubuntu SMP Fri Apr 21 16:42:44 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
Run the following code:
client.js
server.js
How often does it reproduce? Is there a required condition?
Every time
node client.js
is executed.The root of this issue is the proxy inside of
agent.createConnection
.I try to understand the anatomy/life cycle of a http request better.
Especially the role and handling of the agent.
What is the expected behavior? Why is that the expected behavior?
The proxied socket object returned from
agent.createConnection
, should trigger the defined traps. (Dosnt matter if there are any or not).As soon as
agent.createConnection
, return the proxy object, the error is thrown.What do you see instead?
Additional information
Complete command output:
The text was updated successfully, but these errors were encountered: