8000 fix: support response.url in net.fetch by deepak1556 · Pull Request #44725 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: support response.url in net.fetch #44725

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

deepak1556
Copy link
Member
@deepak1556 deepak1556 commented Nov 19, 2024

Description of Change

Addresses Response.url always returns '' (again, we'd have to patch undici to make this work) from #36733 (comment)

This is useful is redirect scenarios where we currently miss the final url, also a prerequisite for #43715

Release Notes

Notes: fix url property in Response object returned by net.fetch

@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Nov 19, 2024
Subject: feat(undici): support urlList initialization in Response ctor

Extends the Response constructor to initialize with urlList array,
which will be used to support the url getter.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codebytere I don't see a way to upstream this change, Response#init options does not support urlList. But we have a unique case of constructing the url list from a different http client (chromium) via undici. Any ideas ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepak1556 I think we could raise an issue or PR and solicit some feedback from undici - maybe they'll be able to support a more generalizable solution that addresses our use case here?

@nikwen
Copy link
Member
nikwen commented Nov 21, 2024

Just read the net.fetch() docs today. If I understand correctly, it would make sense to update this part of the docs:

electron/docs/api/net.md

Lines 100 to 101 in 0005ae9

* The `.type` and `.url` values of the returned `Response` object are
incorrect.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Nov 26, 2024
@matthewjamesadam
Copy link

It would be great to get this fixed -- we have been bitten by this value missing a few times now. Since the typescript type for Response includes a Response.url devs assume it's actually populated correctly, and so the same code that works in browser environments has very different behaviour in electron. Is this fix blocked?

@deepak1556

This comment was marked as outdated.

@deepak1556 deepak1556 force-pushed the robo/support_url_property_fetch_response branch from ff7dbd8 to cc8aefb Compare January 22, 2025 11:13
@deepak1556 deepak1556 marked this pull request as ready for review January 22, 2025 11:18
@deepak1556 deepak1556 requested a review from a team as a code owner January 22, 2025 11:18
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Jan 22, 2025
Copy link
Member
@codebytere codebytere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general approach here looks good to me - from an API perspective i'd mostly just want to initiate conversation upstream alongside this to prevent potential future API breakage if they decide to support something slightly different based on our initial upstream effort!

The patch adds the url chain to the URLResponseHead struct. This is
used to support the Response.url property in the Fetch API.

Should be upstreamed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily a blocker but I'd like to see some feedback from upstream as that potentially could result in subsequent changes to this PR if they want a slightly different API shape or approach or something!

Subject: feat(undici): support urlList initialization in Response ctor

Extends the Response constructor to initialize with urlList array,
which will be used to support the url getter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepak1556 I think we could raise an issue or PR and solicit some feedback from undici - maybe they'll be able to support a more generalizable solution that addresses our use case here?

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0