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

Add missing api::url::URLSearchParams in Body::Initializer. #3151

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

Conversation

balusch
Copy link
Contributor

@balusch balusch commented Nov 21, 2024

Fix #3066

@balusch balusch requested review from a team as code owners November 21, 2024 13:08
@balusch balusch requested review from npaun and fhanau November 21, 2024 13:08
@balusch
Copy link
Contributor Author

balusch commented Nov 21, 2024

Hi @jasnell! Could you please review this PR?

I'm excited and eager to contribute to this project. While browsing the issues, I noticed that #3066 was proposed without a corresponding PR. I decided to address it.

I’m still trying to fully understand the issue (so the PR is still a WIP). I see that both EW_URL_ISOLATE_TYPES (from url.h) and EW_URL_STANDARD_ISOLATE_TYPES (from url-standard.h) are registered in the runtime. They seem similar, but url.h is not compliant with the WHATWG standard. Will they conflict, or does the latter override the former?

I suspect the problem arises because EW_URL_STANDARD_ISOLATE_TYPES overrides EW_URL_ISOLATE_TYPES, causing api::URLSearchParams to not match the JavaScript URLSearchParams object. As a result, the JavaScript URLSearchParams is coerced into a kj::String, leading to the content-type header error. I'm not very sure about that because the codebase is not easy to understand. If there is anything wrong, please correct it for me. :)

src/workerd/api/http.h Outdated Show resolved Hide resolved
Co-authored-by: James M Snell <[email protected]>
Signed-off-by: Jianyong Chen <[email protected]>
@balusch
Copy link
Contributor Author

balusch commented Nov 22, 2024

Hi, @jasnell. I’ve force-pushed an update to add the missing jsg::Ref<url::URLSearchParams> in Body::Initializer. I’ve tested both versions with different compatibilityDate, and they both worked well. I also added you as a co-author in the commit message and hope you don’t mind.

@balusch balusch changed the title WIP: Replace api::URLSearchParams with api::url::URLSearchParams in Body::Initializer. Add missing api::url::URLSearchParams in Body::Initializer. Nov 22, 2024
@jasnell
Copy link
Member

jasnell commented Nov 22, 2024

@balusch ... thank you for the fix! Really appreciated!

@jasnell
Copy link
Member

jasnell commented Nov 22, 2024

Looks like some linting issues with this. I'll fix those up and get this landed.

@jasnell
Copy link
Member

jasnell commented Nov 22, 2024

hmm, actually that passed linting locally. Maybe a CI issue. Let me rerun CI.

@fhanau
Copy link
Collaborator

fhanau commented Nov 22, 2024

CI seems unwell, but looks more like for unrelated network/cache issues... hope those resolve again

@jasnell
Copy link
Member

jasnell commented Nov 22, 2024

ah, ok, I see, there's an issue with our automatic type generation with two URLSearchParam definitions conflicting. We'll need to resolvre that before this can land.

@penalosa said that he'd take a look at what needs to be updated here to fix the type gen issue.

@fhanau
Copy link
Collaborator

fhanau commented Nov 29, 2024

Not to bikeshed some more, but I updated this to fix the comment line length (workerd uses KJ style and thus 100) and use links to the latest tagged release which are shorter.

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.

🐛 Bug Report — URLSearchParams body sets incorrect fetch content-type
4 participants