Skip to content

chore: keep the call context on the event view instead of cloning the request state - #16968

Open
Nic-Polumeyv wants to merge 4 commits into
version-3from
request-context
Open

chore: keep the call context on the event view instead of cloning the request state#16968
Nic-Polumeyv wants to merge 4 commits into
version-3from
request-context

Conversation

@Nic-Polumeyv

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

Copy link
Copy Markdown
Contributor

RequestState carries five booleans that are not about the request. is_in_render, is_in_remote_query, is_in_remote_prerender, is_in_remote_form_or_command and is_in_remote_function say what kind of code is on the stack, and the only way to flip one is to clone the whole state object and re-enter the store with the copy, at 11 sites and twice per query call. It only stays correct because every field mutated inside remote code lives under state.remote, which the spread shares by reference.

Kit already builds a per-call view of the event for remote functions (derive_remote_function_event, which makes url throw inside a query), so the kind of code running is a property of that view. derive_event(event, context) now builds every view and keeps the flags in a non-enumerable __ on it, the same idiom remote functions use for their internals; get_context(event) reads them. The flags accumulate through nested derivations exactly as the spreads did, so behaviour is unchanged, and RequestState keeps only per-request data. allow_cookies was every caller restating the same fact by hand (no cookies inside a query or prerender), so it is now derived from the context.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Aug 27, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 1dd3e60:

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

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

@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1dd3e60

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svelte-docs-bot

Copy link
Copy Markdown

@Nic-Polumeyv
Nic-Polumeyv changed the base branch from version-3 to main August 27, 2026 23:54
@Nic-Polumeyv
Nic-Polumeyv changed the base branch from main to version-3 August 27, 2026 23:55
@Nic-Polumeyv Nic-Polumeyv changed the title chore: move call-context flags out of RequestState into the request store chore: keep the call context on the event view instead of cloning the request state Aug 28, 2026
@Nic-Polumeyv
Nic-Polumeyv marked this pull request as ready for review August 28, 2026 03:56
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