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] support and pin undici 5.12.0 #7412

Merged
merged 3 commits into from
Oct 28, 2022
Merged

Conversation

repsac-by
Copy link
Contributor

Fixes #7409

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 Oct 27, 2022

🦋 Changeset detected

Latest commit: 7873c25

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

@jalavosus
Copy link

Not to knock your fix (it's a good one) but wouldn't a more stable fix be to pin to the last known good version of undici (5.11.0)?

@repsac-by
Copy link
Contributor Author

There are many fixes and improvements in 5.12.0.
I don't see any good reason to stay with 5.11.0 other than the addition of the duplex property.

@N00nDay
Copy link

N00nDay commented Oct 27, 2022

Worked like a charm for me. Thanks repsac-by

@benmccann
Copy link
Member

The Undici team indicated this is the correct fix

This is part of the spec now. When you have a ReadableStream body, the duplex option is required.

@@ -95,6 +95,8 @@ function get_raw_body(req, body_size_limit) {
/** @type {import('@sveltejs/kit/node').getRequest} */
export async function getRequest({ request, base, bodySizeLimit }) {
return new Request(base + request.url, {
// @ts-expect-error
Copy link
Member

Choose a reason for hiding this comment

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

I would expect we shouldn't need this. Is there some detail we can add here about how/when we might be able to remove it. Are the types provided by Typescript or Undici? Is there and open issue we can link to or can we file a new one?

Copy link
Member

Choose a reason for hiding this comment

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

These types appear to be coming from TS, not from undici. Locally, even when I updated the Kit repo to undici 5.12.0, TS still complained about the duplex.

@Conduitry
Copy link
Member

The undici PR included updates to the types here (https://github.com/nodejs/undici/pull/1681/files#diff-cfe294cd3fb885afcce564fae32dd1524399460a9a04f141e07bb45858a47f92), but it looks like we're not using those. I tries this out locally (and updated the Kit repo to undici 5.12.0), but the types for Request appeared to be coming from TypeScript (lib.dom.d.ts) and not from undici. This @ts-expect-error is probably the best we can do for now. Once the types are added to TS and we upgrade, we'll start getting an error here, so at least we'll remember to remove this.

This change looks good to me. Can we get a changeset?

@Conduitry Conduitry changed the title quick fix for undici 5.12.0 [fix] support undici 5.12 Oct 27, 2022
@benmccann
Copy link
Member

We should probably pin the Undici version as well as they've indicated that it's experimental and may have breaking changes in minor/patch versions: nodejs/undici#1681 (comment)

@Conduitry
Copy link
Member

That sounds good to me as well.

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.

+server.ts API endpoint fails to parse body
5 participants