Skip to content

Conversation

dummdidumm
Copy link
Member

  • streams are deduplicated on the client, i.e. same resource+payload == same stream instance
  • a stream is kept open as long as it's either in a reactive context or someone iterates over it. Streams can close when noone listens anymore and open back up when someone does again
  • cannot iterate on the server right now, only retrieve the first value via promise
  • cannot refresh/override (doesn't make sense)

WIP, builds on top of the query-batch PR to avoid merge conflicts like crazy since they touch the same files; the batch PR should be merged first


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. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

- streams are deduplicated on the client, i.e. same resource+payload == same stream instance
- a stream is kept open as long as it's either in a reactive context or someone iterates over it. Streams can close when noone listens anymore and open back up when someone does again
- cannot iterate on the server right now, only retrieve the first value via promise
- cannot refresh/override (doesn't make sense)
Copy link

changeset-bot bot commented Aug 21, 2025

🦋 Changeset detected

Latest commit: a649cf0

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 Minor

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

How confident are we about the deduplication part? For cases where you're streaming a live view of some database query, that makes sense, but are there cases more like this?

for await (const n of countToTen()) {
  console.log(n);
}

It would be weird if I did that and it started at 7 because of something happening in an unrelated component. Genuinely not sure what the right way to think about this is.

@dummdidumm
Copy link
Member Author

dummdidumm commented Aug 22, 2025

yeah I had the same thought already. Hard to tell, both ways make sense - which maybe means we need to give people some way to tell what it is?

Update: maybe it should be "each invocation is a separate stream". Then you can still deduplicate yourself if you want to.

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.

2 participants