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

fix(5383): undici works better with two arguments #5396

Closed
wants to merge 2 commits into from

Conversation

GauBen
Copy link
Contributor

@GauBen GauBen commented Jul 6, 2022

Fixes #5383

I don't know why this works better, but something is wrong on undici's side at step 25:

https://github.com/nodejs/undici/blob/5ca25c23500d649a629865d9a7a28ce653d5e991/lib/fetch/request.js#L321-L341

Specifically, when only one argument is given (as before this PR), init.method gets a default value of GET and erases request.method.


After a bit of research, this was fixed in nodejs/undici#1529


For people that want a quick workaround: patch node_modules/@sveltejs/kit/assets/server/index.js:2304 with:

const external_request = new Request(requested, /** @type {RequestInit} */ (opts));
response = await options.hooks.externalFetch.call(null, external_request.url, external_request);

and restart the dev server.


I'll open the PR nonetheless because svelte-kit seems to release faster than undici.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Jul 6, 2022

🦋 Changeset detected

Latest commit: 41a5a2c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@GauBen
Copy link
Contributor Author

GauBen commented Jul 6, 2022

I thought this would be a quick fix, but I don't know the implications of changing this type:

https://github.com/GauBen/kit/blob/41a5a2cb760e70a10bc7237542f95363678564f0/packages/kit/types/index.d.ts#L157-L159

Probably a big deal because it's in the public-facing API. (Edit: indeed)

@GauBen GauBen closed this Jul 6, 2022
@GauBen GauBen mentioned this pull request Jul 8, 2022
5 tasks
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.

next.359 - load fetch POST => Request with GET/HEAD method cannot have body
1 participant