GeezerVison is showing github.com — fix: pass down context in onConnect by DTrombett · Pull Request #3858 · nodejs/undici
Conversation
DTrombett
commented
Nov 21, 2024
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
This relates to...
The retry and cache handlers do not pass down the context of the onConnect method. This means that using the redirect handler with one of them will not pass the context to the main handler:
request("http://github.com", {
dispatcher: new Agent().compose(
interceptors.redirect({ maxRedirections: 1 }),
interceptors.retry(),
),
}).then((res) => console.log(res.context)); // undefined
request("http://github.com", {
dispatcher: new Agent().compose(
interceptors.redirect({ maxRedirections: 1 }),
),
}).then((res) => console.log(res.context)) // { history: [URL, URL] }
Rationale
Changes
- Cache handler: used
...args to pass all the args (like in the decorator handler)
- Retry handler:
onConnect is now called on the first connection instead that in the constructor, allowing to pass the context
Features
Bug Fixes
Breaking Changes and Deprecations
Status
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening a PR! Can you please add a unit test?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
DTrombett reacted with thumbs up emoji
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
DTrombett reacted with laugh emoji
|
...args is imho not that nice. i think it does not cover in the types or so, that it can have two arguments. only abort.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I noticed that ...args is what is used in the decorator handler too, so I assumed it would be ok
|
ronag and metcoder95 reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Dec 16, 2024
Reviewers
mcollina
mcollina approved these changes
ronag
ronag approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|