Skip to content

chore: configure the server runtime in one place - #17000

Merged
teemingc merged 7 commits into
version-3from
server-boot
Sep 18, 2026
Merged

teemingc merged 7 commits into
version-3from
server-boot

Conversation

@Nic-Polumeyv

@Nic-Polumeyv Nic-Polumeyv commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Kit sets up its server runtime in six places: Server.init, prerender, analyse, dev, preview and the fallback generator. Each calls a different subset of the same module-level setters by hand, in an order four comments explain. The Server class itself holds no state since #16967, its constructor is set_manifest.

configure in the generated server module now owns that order, and init and respond replace the class. The server object adapters get from generateServerInstance is unchanged and still only accepts env and read, so the internal options configure takes (building, prerendering, manifest) are not reachable through it. Server stays as a deprecated shim.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 72cfe25:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/72cfe2552d8397e680a255293fd5b2e0640224a1

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

@changeset-bot

changeset-bot Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 72cfe25

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

@svelte-docs-bot

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: QUIET

Plan: Advanced

Run ID: 2daaeb57-d5ca-4a40-94b5-ba3b0293f0df

📥 Commits

Reviewing files that changed from the base of the PR and between 8b5a96f and 72cfe25.

📒 Files selected for processing (1)
  • packages/kit/src/runtime/server/index.js
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • sveltejs/vite-plugin-svelte (manual)
  • vitejs/vite (manual)
  • sveltejs/svelte (manual)

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The server lifecycle now uses module-level configure, init, respond, and create_server APIs. Build, prerender, fallback, analysis, development, preview, generated modules, type declarations, test instrumentation, and migration documentation use the updated API surface. The deprecated Server class delegates to the new implementation.

Priority: ➖ Normal — Schedule the server runtime centralization because it changes initialization and request handling across build, prerender, development, preview, fallback, and public type APIs.

Merge Risk: ⚪ Minimal · up to 72cfe

Server lifecycle setup is centralized behind module-level APIs while preserving HEAD responses without bodies. No concrete current-head merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required chore: prefix and clearly describes the centralised server runtime configuration change.
Backward Compatibility Impact Disclosure ✅ Passed No breaking public interface change is introduced. The public Server and ServerInitOptions declarations are unchanged, and the runtime still exports Server; it adds init, respond, and `creat…

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/kit/src/runtime/server/index.js

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Nic-Polumeyv
Nic-Polumeyv marked this pull request as draft September 2, 2026 05:07
@Nic-Polumeyv
Nic-Polumeyv marked this pull request as ready for review September 2, 2026 14:25

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, just one nit to look at before we merge

Comment thread packages/kit/src/core/postbuild/prerender.js

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additional Suggestion:

HEAD response bodies are not stripped when adapters use the recommended create_server()/respond path, only in the deprecated Server.respond wrapper.

Fix on Vercel

…mmended `create_server()`/`respond` path, only in the deprecated `Server.respond` wrapper.

This commit fixes the issue reported at packages/kit/src/runtime/server/index.js:201

## Bug

On the `version-3` branch, HEAD-body stripping lived in the single `Server.respond` method that every adapter used:

```js
if (request.method === 'HEAD' && response.body !== null) {
    response.body.cancel().catch(noop);
    return new Response(null, response);
}
```

After the refactor, the shared implementation moved into the module-level `respond_to()` function, and `create_server()` returns `{ init, respond }` where `respond = respond_to` (or a serialised wrapper). Adapters generated via `builder.generateServerInstance` use this path:

- `packages/adapter-vercel/files/serverless.js` → `server.respond(request, {...})`
- `packages/adapter-cloudflare/files/worker.js` → `await server.respond(req, {...})`
- `packages/adapter-netlify/files/edge.js` → `server.respond(request, {...})`
- `packages/adapter-netlify/files/serverless.js` → `server.respond(request, {...})`

But the merge added the HEAD handling **only** to the deprecated `Server.respond` method, not to `respond_to`. So the `create_server().respond` / standalone `respond` paths did not strip HEAD bodies.

### Failure mode

A `HEAD` request routed through any edge/serverless adapter that returns the `Response` directly to the platform (no HTTP layer to discard the body). The returned `Response` includes a body, which is a regression from version-3 — wasting bandwidth and violating HTTP HEAD semantics for clients.

## Fix

Moved the HEAD-body stripping into `respond_to()` so all respond paths (`create_server().respond`, the standalone `respond` export, and the deprecated `Server.respond`) benefit. Simplified the now-redundant deprecated `Server.respond` wrapper to just delegate to `this.#server.respond`. `noop` was already imported at the top of the file.

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: teemingc <chewteeming01@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

🟡 Other comments (1)
packages/kit/src/runtime/server/index.js-196-202 (1)

196-202: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Apply HEAD normalisation to the exported respond path.

create_server exposes the module-level respond directly. The body cancellation and bodyless Response conversion exist only in this deprecated Server wrapper. A direct create_server(...).respond() call can therefore return a non-null body for a HEAD request. Move this logic into the shared response path and add a regression test for the generated server path.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: QUIET

Plan: Advanced

Run ID: fb915e0c-094b-4b84-afbe-9b967a0e4f23

📥 Commits

Reviewing files that changed from the base of the PR and between c440ed4 and 8b5a96f.

📒 Files selected for processing (1)
  • packages/kit/src/runtime/server/index.js
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • sveltejs/vite-plugin-svelte (manual)
  • vitejs/vite (manual)
  • sveltejs/svelte (manual)

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@teemingc
teemingc merged commit c6ba86b into version-3 Sep 18, 2026
41 checks passed
@teemingc
teemingc deleted the server-boot branch September 18, 2026 20:57
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