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

req.socket might be null #42

Open
Gerhut opened this issue Jul 3, 2022 · 3 comments
Open

req.socket might be null #42

Gerhut opened this issue Jul 3, 2022 · 3 comments
Assignees

Comments

@Gerhut
Copy link

Gerhut commented Jul 3, 2022

See discussion in nodejs/undici#1115, nodejs/node#41011.

There will be TypeError: Cannot read properties of null (reading 'destroy') when using req as body in undici.stream, which sets req.socket to null.

@dougwilson
Copy link
Contributor

Thanks for reporting, @Gerhut ! I do indeed see the Node.js docs have updated to note that req.socket is no longer guaranteed to be there, and that there is a code path within Node.js itself that now unsets it. I will get a patch out for this module to account for this new behavior.

@dougwilson dougwilson self-assigned this Jul 4, 2022
@dougwilson
Copy link
Contributor

Sorry for the delay on this. It seems very convoluted on when exactly Node.js will make req.socket null. I see that there is a guard against that in req.destroy(), though not a lot of other methods on req. I believe we can just call req.destroy() anyway, just verifying that will behave as expected across the supported Node.js versions of this module before landing, as it would be the simplest solution 👍

@blazzy
Copy link

blazzy commented Jun 21, 2023

@dougwilson Any luck with this? I'm running into an occasional error where req.socket is null and req.socket.destroy ends up blowing up.
Undici in particular is clearing out the socket when we stream a request through it and the connection is suddenly killed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants