Skip to content

chore: merge the server request state into one object - #16605

Merged
Rich-Harris merged 9 commits into
sveltejs:version-3from
Nic-Polumeyv:unify-request-state
Aug 7, 2026
Merged

chore: merge the server request state into one object#16605
Rich-Harris merged 9 commits into
sveltejs:version-3from
Nic-Polumeyv:unify-request-state

Conversation

@Nic-Polumeyv

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

Copy link
Copy Markdown
Contributor

Part of #16519, doing the unification suggested in #16507 (comment). One request state object, forked for event.fetch sub-requests. This also makes the state.prerendering-in-dev idea from #16507 workable, since there's no second carrier to desync from anymore.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Aug 1, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 4699641:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/4699641c2525b57373fa13d8d30d9d62828a2f07

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

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4699641

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

@Nic-Polumeyv
Nic-Polumeyv marked this pull request as ready for review August 1, 2026 04:07
@Nic-Polumeyv
Nic-Polumeyv force-pushed the unify-request-state branch 2 times, most recently from 7c3b5a5 to ca1d01c Compare August 2, 2026 00:04
@Rich-Harris

Copy link
Copy Markdown
Member

Unfortunately this'll need a rebase now that #16600 is closed

@Nic-Polumeyv
Nic-Polumeyv marked this pull request as draft August 5, 2026 19:37
@Nic-Polumeyv
Nic-Polumeyv marked this pull request as ready for review August 6, 2026 17:23
Comment thread packages/kit/src/runtime/server/state.js Outdated
depth: 0,
handleValidationError: hooks.handleValidationError,
tracing: {
record_span

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

occurs to me that we never reassign this, we could probably just import record_span in all the places we need to call it — not for this PR, but an easy follow-up

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this. sequence is the only place left, and it can't import it: hooks is externalized in SSR, so otel.js throws on the unreplaced SVELTEKIT_SERVER_TRACING_ENABLED define. Trying to see if i can find something clever

@Rich-Harris Rich-Harris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so much cleaner!

@Nic-Polumeyv
Nic-Polumeyv changed the base branch from version-3 to main August 6, 2026 23:27
@Nic-Polumeyv
Nic-Polumeyv changed the base branch from main to version-3 August 6, 2026 23:28
@Rich-Harris
Rich-Harris merged commit ba0263d into sveltejs:version-3 Aug 7, 2026
3 of 4 checks passed
@Nic-Polumeyv
Nic-Polumeyv deleted the unify-request-state branch August 7, 2026 05:51
Rich-Harris pushed a commit that referenced this pull request Aug 8, 2026
#16675)

Follow-up to
#16605 (comment), using
the #16658 treatment so it works from `sequence`. On top of #16605.
elliott-with-the-longest-name-on-github added a commit that referenced this pull request Aug 20, 2026
…he server runtime (#16871)

`options` is already a single module-level object:
`runtime/server/index.js` imports it from
`<sveltekit:generated>/server.js` and `Server.init` writes `hooks` onto
it, so every `Server` in a process shares it. It was also passed through
17 parameter positions, from `internal_respond` down to
`static_error_page`, plus the `RemoteInternals.run` callback.

It now sits in `runtime/server/internal.js` next to `manifest` and
`read_implementation`, and `hooks` gets its own `set_hooks()` there, so
`options` is immutable build data once `set_options` has run.
`set_options` is called at module scope rather than in the constructor,
so it lands before prerendering evaluates the user's remote modules,
which happens before any `Server` is constructed.

`fetch.js` renames its destructured set-cookie `options` to
`cookie_options`, which would otherwise shadow the import.

Follow-up to
#16605 (comment). Part
of #16519.
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.

2 participants