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

Undici #5117

Merged
merged 23 commits into from Jun 28, 2022
Merged

Undici #5117

merged 23 commits into from Jun 28, 2022

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented May 30, 2022

#5113. This replaces node-fetch with undici, which is more standards-compliant and is built in to Node 18. This will unlock using web streams for request and response bodies, on platforms that support them.

TODO:

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 May 30, 2022

🦋 Changeset detected

Latest commit: 1ef7340

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

@Rich-Harris
Copy link
Member Author

Rich-Harris commented May 30, 2022

The handles large responses test is failing for reasons I have been unable to figure out

test('handles large responses', async ({ page }) => {
await page.goto('/load');
const chunk_size = 50000;
const chunk_count = 100;
const total_size = chunk_size * chunk_count;
let chunk = '';
for (let i = 0; i < chunk_size; i += 1) {
chunk += String(i % 10);
}
let times_responded = 0;
const { port, server } = await start_server(async (req, res) => {
if (req.url === '/large-response.json') {
times_responded += 1;
res.writeHead(200, {
'Access-Control-Allow-Origin': '*'
});
for (let i = 0; i < chunk_count; i += 1) {
if (!res.write(chunk)) {
await new Promise((fulfil) => {
res.once('drain', () => {
fulfil(undefined);
});
});
}
}
res.end();
}
});

@Rich-Harris
Copy link
Member Author

oh and a bunch of packaging tests have started failing for absolutely no good reason whatsoever. jfc software is awful

@Rich-Harris
Copy link
Member Author

ok i think the unrelated packaging tests are failing because this PR installs undici from git, which means it's pulling in dev dependencies that mess up some stuff. programming is super fun

@Rich-Harris Rich-Harris mentioned this pull request May 30, 2022
@pixelmund
Copy link
Contributor

Seems like undici had a new release, so we can remove the git dependency now.

@Rich-Harris
Copy link
Member Author

I don't really understand why handles large responses is starting a second server

Because before undici it wasn't possible to generate a chunked response from a SvelteKit app. That's no longer the case, so I've updated the test — instead of generating the response in a second server, it does it in an endpoint

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.

Swap out node-fetch for undici
4 participants