Skip to content

chore: read the request state from the event instead of threading it alongside - #16969

Open
Nic-Polumeyv wants to merge 4 commits into
request-contextfrom
request-state-on-event
Open

chore: read the request state from the event instead of threading it alongside#16969
Nic-Polumeyv wants to merge 4 commits into
request-contextfrom
request-state-on-event

Conversation

@Nic-Polumeyv

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

Copy link
Copy Markdown
Contributor

RequestState is passed as an (event, state) pair through 16 functions in runtime/server, and the request store exists to carry the same pair to $app/server code. Every function that has the event already has the request, so both are redundant.

respond.js now registers the state in a WeakMap keyed by event.request and get_state(event) reads it back. The request is the one object that exists once per request and survives every { ...event } copy, so nothing is added to the event itself; the live-query event replaces request and re-attaches. With the state reachable from the event, the store has nothing of its own left: with_request_store({ event, state }) becomes with_event(event), get_request_store() becomes get_event(), and RequestStore is gone. The 16 signatures take event alone; internal_respond, internal_fetch and fork_state_for_subrequest still take state because they run before the event exists.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Aug 27, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 3caf1f5:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/3caf1f5090ee952f5450f4a440ca7d636bd20b2a

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

@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3caf1f5

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 force-pushed the request-state-on-event branch from 9a99f6e to b0d8267 Compare August 28, 2026 00:02
@Nic-Polumeyv
Nic-Polumeyv force-pushed the request-state-on-event branch 5 times, most recently from c47397d to 6f3c17a Compare August 28, 2026 01:32
@Nic-Polumeyv
Nic-Polumeyv force-pushed the request-state-on-event branch from 6f3c17a to 3caf1f5 Compare August 28, 2026 01:40
@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