Skip to content

Conversation

Rich-Harris
Copy link
Member

We don't worry about preserving context for ordinary expressions ({await x}) because nothing comes after them. But we do need to preserve context for things like if blocks, because they can contain calls (to push, push_element etc) that need to be able to attach to the correct context.

This fixes it. Going to self-merge to unblock SvelteKit async SSR exploration

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
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Sep 18, 2025

🦋 Changeset detected

Latest commit: b414de0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte 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

@svelte-docs-bot
Copy link

Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@16791

@Rich-Harris Rich-Harris merged commit e4ebca9 into main Sep 18, 2025
18 checks passed
@Rich-Harris Rich-Harris deleted the preserve-ssr-context branch September 18, 2025 02:29
@github-actions github-actions bot mentioned this pull request Sep 18, 2025
@wiesson
Copy link

wiesson commented Sep 18, 2025

Since this PR, I get "Error: Could not get the request store." on every SSR render with remote functions - not sure if I need to adapt sth. More interesting, it happens on dev, not prod

usage

getMembers is a remote function/query

let members = $derived(getMembers({ organizationId, teamId, searchQuery, suspended }));

error:

Error: Could not get the request store. This is an internal error.
    at get_request_store (file:path-to-project/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_svelte_023f488ff8fb3407a93984b212a90d71/node_modules/@sveltejs/kit/src/exports/internal/event.js:48:9)
    at wrapper (../../node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_svelte_023f488ff8fb3407a93984b212a90d71/node_modules/@sveltejs/kit/src/runtime/app/server/remote/query.js:73:45)
    at /Users/wiese/Dev/tm/tourvy-app-main/apps/tourvy/src/lib/components/features/members/members-list.svelte:22:35
    at Renderer.child (../../node_modules/.pnpm/[email protected]/node_modules/svelte/src/internal/server/renderer.js:112:18)
    at Renderer.component (../../node_modules/.pnpm/[email protected]/node_modules/svelte/src/internal/server/renderer.js:137:22)
    at Members_list (src/lib/components/features/members/members-list.svelte:21:14)
    at eval (src/routes/(app)/[teamSlug]/members/+page.svelte:22:37)
    at Renderer.child (../../node_modules/.pnpm/[email protected]/node_modules/svelte/src/internal/server/renderer.js:112:18)
    at Renderer.component (../../node_modules/.pnpm/[email protected]/node_modules/svelte/src/internal/server/renderer.js:137:22)
    at _page (src/routes/(app)/[teamSlug]/members/+page.svelte:17:14)

// edit: I can't say since when it's happening, I need to debug a little further.

@Antonio-Bennett
Copy link

@wiesson pretty sure you're encountering this issue. TLDR - If you're using Sveltekit Async SSR isn't supported yet

@wiesson
Copy link

wiesson commented Sep 18, 2025

Ok, I'll just wait

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.

3 participants