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

getSocketAddr returned undefined, when the socket is disconnected #12

Open
Shonke opened this issue May 16, 2022 · 6 comments
Open

getSocketAddr returned undefined, when the socket is disconnected #12

Shonke opened this issue May 16, 2022 · 6 comments

Comments

@Shonke
Copy link

Shonke commented May 16, 2022

https://github.com/jshttp/forwarded/blob/master/index.js#L46

image

image

@dougwilson
Copy link
Contributor

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!

@Shonke
Copy link
Author

Shonke commented May 17, 2022

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

@Shonke
Copy link
Author

Shonke commented May 17, 2022

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

@dougwilson
Copy link
Contributor

dougwilson commented May 17, 2022

For nodejs, this is not a bug:
"Value may be undefined if the socket is destroyed"

Gotcha. So then what is the issue about?

@dougwilson
Copy link
Contributor

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.

@YangJonghun
Copy link

YangJonghun commented Sep 27, 2022

@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

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

No branches or pull requests

3 participants