Skip to content

fix: serialize server load data before passing to universal load, to handle mutations - #14268

Merged
Rich-Harris merged 3 commits into
mainfrom
gh-12236
Aug 19, 2025
Merged

Rich-Harris merged 3 commits into
mainfrom
gh-12236

Conversation

@Rich-Harris

Copy link
Copy Markdown
Member

Fixes #12236. The implementation isn't totally ideal — it causes the server load return value to be serialized twice if data is used in a universal load function, and changing that would be finicky — but given our overall trajectory towards remote functions I think it's an acceptable trade-off given that using data is probably relatively rare (and it only affects SSR, not data for subsequent client-side navigations).


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

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:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@svelte-docs-bot

Copy link
Copy Markdown

@changeset-bot

changeset-bot Bot commented Aug 19, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5aab6bf

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
Rich-Harris merged commit c5a9794 into main Aug 19, 2025
@Rich-Harris
Rich-Harris deleted the gh-12236 branch August 19, 2025 20:45
@github-actions github-actions Bot mentioned this pull request Aug 19, 2025
PatrickG added a commit to PatrickG/kit that referenced this pull request Aug 22, 2025
Rich-Harris added a commit that referenced this pull request Aug 28, 2025
…ternative (#14298)

* add universal load to /streaming/server test

* revert #14268

* server data serializer

* Satisfy linter

* rethrow serialization error after load promises are resolved

* format

* add changeset

* get rid of the global placeholder

* fix dumb mistake

* fix errors

* return directly again

* return iterator even if all promises are resolved already

* prevent memory leak

* format

* use `DEV` from `esm-env`

* revert reordering

* revert reordering

* revert reordering

* revert reordering

* remove type, everything is a type in a .d.ts file

* revert reordering

* serialize -> add_node

* unused

* simplify create_async_iterator

* avoid the need for set_nonce dance

---------

Co-authored-by: Rich Harris <[email protected]>
Copilot AI pushed a commit to Stadly/kit that referenced this pull request Mar 6, 2026
… to handle mutations (sveltejs#14268)

* failing test

* fix: serialize server `load` data before passing to universal `load`, to handle mutations

* ugh
Copilot AI pushed a commit to Stadly/kit that referenced this pull request Mar 6, 2026
…ternative (sveltejs#14298)

* add universal load to /streaming/server test

* revert sveltejs#14268

* server data serializer

* Satisfy linter

* rethrow serialization error after load promises are resolved

* format

* add changeset

* get rid of the global placeholder

* fix dumb mistake

* fix errors

* return directly again

* return iterator even if all promises are resolved already

* prevent memory leak

* format

* use `DEV` from `esm-env`

* revert reordering

* revert reordering

* revert reordering

* revert reordering

* remove type, everything is a type in a .d.ts file

* revert reordering

* serialize -> add_node

* unused

* simplify create_async_iterator

* avoid the need for set_nonce dance

---------

Co-authored-by: Rich Harris <[email protected]>
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.

mutating the data prop in a universal load affects the data returned from a server load

2 participants