Split client and server transporters
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
The transport hook added in 2.11.0 is insufficient for returning long lived variables from load functions, such as ReadableStreams/async iterators and Observables
Describe the proposed solution
Split the transport encode/decode into hooks.server.js and hooks.client.js to allow for long lived variables to be serialized into IDs by the user, then revived on the client using an SSE or Websocket connection, similar to how Promises are already serialized into unique IDs that are attached to the window and resolved later.
Ideally this should also not leak the server implementation to the client
Alternatives considered
You can return an ID from a load function, then set up the SSE connection from the client, but this is brittle and not reusable
Importance
nice to have
Additional Information
Feature announcement: https://bsky.app/profile/svelte.dev/post/3ld4ncjryfs2g
Feature PR: https://github.com/sveltejs/kit/pull/13149
PR that would fix this: https://github.com/sveltejs/kit/pull/13125
Similar to: https://github.com/sveltejs/kit/issues/13156
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the transport encode/decode hooks described in the issue, along with hooks.server.js and hooks.client.js and the linked PRs 13149 and 13125. Done means server and client transporters are split so long-lived values can be serialized and revived without leaking the server implementation to the client.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- full-stack, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100