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

Merged
merged 4 commits into from
Dec 3, 2024

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. :)

@balusch balusch force-pushed the fix-body-initializer branch from c8ba969 to 1650021 Compare November 22, 2024 01:37
@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 fhanau force-pushed the fix-body-initializer branch from c0f5da8 to 2f58c06 Compare November 29, 2024 17:54
@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.

@balusch
Copy link
Contributor Author

balusch commented Dec 1, 2024

Hi @fhanau Thanks for your update. However, the ci still failed and it seems that there is something wrong with the Bazel remote cache (maybe similar to this issue but not sure). Could you please re-trigger the ci?

@fhanau
Copy link
Collaborator

fhanau commented Dec 1, 2024

The Windows build appears thoroughly broken unfortunately – I'll try to see on Monday if flushing the cache entirely helps here.
Edit: Now it suddenly seems to be working 🤷

@fhanau
Copy link
Collaborator

fhanau commented Dec 2, 2024

@penalosa any remaining concerns or can I merge this?

@jasnell
Copy link
Member

jasnell commented Dec 2, 2024

@fhanau ... let's do an internal CI run on this just to be extra safe.

@fhanau fhanau force-pushed the fix-body-initializer branch from 2f58c06 to 67c375d Compare December 2, 2024 17:34
@fhanau fhanau force-pushed the fix-body-initializer branch from 67c375d to acefd77 Compare December 2, 2024 19:31
@fhanau fhanau requested a review from a team as a code owner December 2, 2024 19:31
@fhanau
Copy link
Collaborator

fhanau commented Dec 2, 2024

Regenerated the types as required by CI now, which revealed the next problem... URLSearchParams is listed twice in the types definition? @penalosa

@penalosa
Copy link
Collaborator

penalosa commented Dec 3, 2024

Regenerated the types as required by CI now, which revealed the next problem... URLSearchParams is listed twice in the types definition? @penalosa

I think that's fine. It's a bit messy but it shouldn't cause any type errors (since they point to the same definition). I can't really see any easy way around that unless we get a lot more invasive with the C++ definitions based on compat flag

@penalosa
Copy link
Collaborator

penalosa commented Dec 3, 2024

The Windows build appears thoroughly broken unfortunately – I'll try to see on Monday if flushing the cache entirely helps here. Edit: Now it suddenly seems to be working 🤷

This is a fork, so I don't think the cache is being used, which is probably why the builds are so slow

@jasnell jasnell merged commit 5ee569c into cloudflare:main Dec 3, 2024
12 checks passed
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