forwarded
forwarded copied to clipboard
getSocketAddr returned undefined, when the socket is disconnected
https://github.com/jshttp/forwarded/blob/master/index.js#L46
Hello, and thank you for the report. This is the API from Node.js; if you are trying to report this as a bug, you will need to report to Node.js, but if you are trying to report it as a bug to this module, please help us by providing what API should be used instead, thank you!
Hello, and thank you for the report. This is the API from Node.js; if you are trying to report this as a bug, you will need to report to Node.js, but if you are trying to report it as a bug to this module, please help us by providing what API should be used instead, thank you!
For nodejs, this is not a bug: "Value may be undefined if the socket is destroyed" https://nodejs.org/dist/latest-v16.x/docs/api/net.html#socketremoteaddress
undefined can cause unexpected damage, and it is described as string[] in types https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/forwarded/index.d.ts#L11
For nodejs, this is not a bug: "Value may be undefined if the socket is destroyed"
Gotcha. So then what is the issue about?
undefined can cause unexpected damage, and it is described as string[] in types
I'm not sure what this means. If you are saying there is an issue with the typings, you'll need to open an issue on the definatelytyped repo.
@dougwilson
getSocketAddr have problem because req.socket can be null.
this code makes below TypeError
.../forwarded/index.js:49
: req.connection.remoteAddress
^
TypeError: Cannot read properties of null (reading 'remoteAddress')
fyi) https://nodejs.org/dist/latest-v16.x/docs/api/http.html#messagesocket
... or internally nulled