Pass ip, ips, and hostname to Request object#1476
Conversation
delvedor
left a comment
There was a problem hiding this comment.
Is this a breaking change?
We are no longer writing the values in the Node Core request object, but in ours.
Hi @delvedor: Do you mean this particular commit a breaking change or this pull request? The call to Thanks, Tomas. New to fastify. |
Dismissing my "Accept" because I agree with @mcollina's suggestion to refactor the code so that it doesn't allocate any new objects.
Yes, removing those values makes this a breaking change. Another option would be to add the values to Fastify's |
|
Changes LGTM ✨ |
|
master branch: pass-ip-to-request-constructor: Per @mcollina 's comment:
|
mcollina
left a comment
There was a problem hiding this comment.
Can you please make this change non semver major? The properties must still be on the raw objects.
mcollina
left a comment
There was a problem hiding this comment.
Can you run a quick autocannon benchmark against the example before & after this change with the option on and off?
Also, the typescript def & test should be updated.
| var logger = log.child({ reqId: req.id }) | ||
| if (optAddToNodeReq) { | ||
| req.log = res.log = logger | ||
| } |
There was a problem hiding this comment.
We might want to add ip here as well.
Would that be useful?
There was a problem hiding this comment.
Something like this?
if (optAddToNodeReq) {
req.ip = req.connection.remoteAddress
req.log = res.log = logger
}I don't know in what scenario how it would be useful... so I would not add it.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Checklist
npm run testandnpm run benchmarkAdd ip, ips, and hostname in
Requestobject. Related to @delvedor's feedback at #1086 (comment). All credits go to @nwoltman . Without his guidance, the work won't be possible.benchmarks