Skip to content

fix: stream promised read results lazily - #16622

Open
Nic-Polumeyv wants to merge 1 commit into
sveltejs:version-3from
Nic-Polumeyv:wrapped-read-stream
Open

fix: stream promised read results lazily#16622
Nic-Polumeyv wants to merge 1 commit into
sveltejs:version-3from
Nic-Polumeyv:wrapped-read-stream

Conversation

@Nic-Polumeyv

@Nic-Polumeyv Nic-Polumeyv commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Promised read() results held the whole file in memory instead of streaming it. ReadableStream.from exists everywhere the server runtime ships (Node 20.6+, workerd, Deno, Vercel edge).

Partial reads of a 100MB file drop from 82MB of memory to basically nothing, huge win.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Aug 3, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from d26ff54:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/d26ff54def3fa95bc4c670989b5a4e46210b12db

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16622

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d26ff54

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

});
}

// TODO remove the cast once TypeScript's lib includes `ReadableStream.from`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wrapped_read uses ReadableStream.from() and async iteration of a ReadableStream (yield* stream), which are not supported on Cloudflare's workerd runtime, throwing at runtime when server-side asset reads occur on the Cloudflare adapter.

Fix on Vercel

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.

1 participant