req.socket might be null
See discussion in https://github.com/nodejs/undici/issues/1115, https://github.com/nodejs/node/issues/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.
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.
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 👍
@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.