question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sometimes request.ip returns undefined

See original GitHub issue

After certain types of errors (e.g. { [Error: Parse Error] bytesParsed: 159, code: 'HPE_INVALID_METHOD' }) the remote socket gets closed, and calling .remoteAddress on it will return undefined.

Because koa’s request.ip is lazy, this means it’s sometimes returning undefined which screws up some things (e.g. I record errors in a format that requires an ip, and would like to see the ip address of the bad requests).

I think this is quite unexpected behavior, and would be more sensible to strictly evaluate .ip to always be available

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
PlasmaPowercommented, Mar 25, 2016

I’m making a PR now, it’s almost done

5reactions
PlasmaPowercommented, Mar 25, 2016

I’d be in favor of caching the value. It could be set in createContext. The request IP shouldn’t be changing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Client IP is sometimes undefined in a Nodejs app hosted in ...
I really don't know what that is and I'm doubting that whenever its making the request, the IP is returning undefined . UPDATE....
Read more >
[@types/express-serve-static-core] Request.ip should be ...
So, after looking into it, the reason why req.ip can be undefined is because req.connection.remoteAddress is used as part of deriving req.ip ...
Read more >
Client IP is sometimes undefined in a Nodejs app hosted in ...
I have rather an unusual problem with my app. The app heavily depends on the client's IP which is sometimes undefined .
Read more >
$request->ip() undefined
I have two methods to which I pass Request object: Copy Code public function pull(Request $requestSvr) { if($requestSvr->user()->tokenCan('update')) ...
Read more >
How to get a client IP Address in Node.js (6 ways)
Learn How to get a client IP Address using Node.js in 6 ... If they do not set XFF, the optional chaining operator...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found