Repository navigation
chore: bundle adapter-node's server source directly instead of prebuilding it with rolldown - #17109
Merged
Merged
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/fe20a80ab18d363c00e7ab4308400778cf02dd68Open in |
🦋 Changeset detectedLatest commit: fe20a80 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Nic-Polumeyv
force-pushed
the
adapter-node-drop-prebuild
branch
2 times, most recently
from
September 14, 2026 23:38
e308b55 to
ccfa2ce
Compare
Nic-Polumeyv
force-pushed
the
manifest-static-assets
branch
2 times, most recently
from
September 14, 2026 23:51
6a1bf95 to
a025f33
Compare
Nic-Polumeyv
force-pushed
the
adapter-node-drop-prebuild
branch
from
September 14, 2026 23:51
ccfa2ce to
348f74f
Compare
Nic-Polumeyv
force-pushed
the
manifest-static-assets
branch
from
September 14, 2026 23:59
a025f33 to
36b547b
Compare
Nic-Polumeyv
force-pushed
the
adapter-node-drop-prebuild
branch
from
September 14, 2026 23:59
348f74f to
c6538b5
Compare
Nic-Polumeyv
added this pull request to stack #17110
September 15, 2026 00:09
Nic-Polumeyv
marked this pull request as ready for review
September 15, 2026 00:14
Rich-Harris
approved these changes
Sep 15, 2026
Nic-Polumeyv
removed this pull request from stack #17110
September 17, 2026 19:30
Nic-Polumeyv
force-pushed
the
adapter-node-drop-prebuild
branch
from
September 17, 2026 19:32
23fd551 to
e4d272b
Compare
Nic-Polumeyv
force-pushed
the
manifest-static-assets
branch
from
September 17, 2026 19:32
7b933e3 to
28d211a
Compare
Nic-Polumeyv
added this pull request to stack #17126
September 17, 2026 19:32
An unhandled read stream error (a file deleted from the build output, EMFILE) crashed the process. Headers are already sent by then, so drop the connection.
…from the original hash
teemingc
force-pushed
the
manifest-static-assets
branch
from
September 18, 2026 20:39
28d211a to
3b68018
Compare
Nic-Polumeyv
force-pushed
the
adapter-node-drop-prebuild
branch
from
September 18, 2026 22:39
e4d272b to
e39f45e
Compare
Nic-Polumeyv
removed this pull request from stack #17126
September 19, 2026 13:29
…efore the asset lookup, blocking all POST/PUT/DELETE/PATCH/OPTIONS requests to any path and preventing SvelteKit SSR (form actions, `+server.js` handlers, remote functions, CORS preflight) from ever running.
This commit fixes the issue reported at packages/adapter-node/src/static.js:172
## Bug
In `packages/adapter-node/src/static.js`, `serve_static` returned the middleware:
```js
return (req, res, next) => {
if (req.method !== 'GET' && req.method !== 'HEAD') {
res.writeHead(405, { allow: 'GET, HEAD' });
res.end();
return;
}
const { pathname, search } = split_url(req);
const asset = files.get(pathname);
if (!asset) return next();
...
```
The method check runs **before** the asset lookup and **before** `next()`. Because the handler is wired as `sequence([serve_static(...), ssr])` (see `packages/adapter-node/src/handler.js`), `serve_static` runs first for **every** request.
### Failure mode / trigger
Any non-GET/HEAD request to a non-asset path (e.g. `POST /login`, `PUT /api/item`, `DELETE /api/x`, `PATCH ...`, or a CORS `OPTIONS` preflight) is short-circuited with `405 Allow: GET, HEAD` and never reaches the SSR handler. This breaks:
* Form actions (`POST` to `+page.server.js` actions)
* API routes (`+server.js` `POST`/`PUT`/`DELETE`/`PATCH` handlers)
* Remote functions
* CORS preflight (`OPTIONS`)
This is a regression from the previous `sirv`-based behavior, which forwarded non-GET/HEAD methods to `next()`.
## Fix
Move the 405 check to **after** the asset lookup and the redirect (`location`) handling, so the method restriction only applies when the path actually maps to a real static asset:
```js
const { pathname, search } = split_url(req);
const asset = files.get(pathname);
if (!asset) return next();
if ('location' in asset) {
res.writeHead(308, { location: asset.location + search }).end();
return;
}
if (req.method !== 'GET' && req.method !== 'HEAD') {
res.writeHead(405, { allow: 'GET, HEAD' });
res.end();
return;
}
```
Now non-asset paths fall through to `next()` regardless of method, while a disallowed method on an actual static asset still correctly returns 405.
## Test
The existing test `disallows non-GET/HEAD methods` POSTs to `/plain.txt` (a real asset) and still passes. I added a regression test `passes non-GET/HEAD requests to non-asset paths to the next handler` that POSTs to `/missing.txt` and asserts it reaches the next handler (status 404, body `next`), which fails on the old code and passes on the fixed code.
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: teemingc <chewteeming01@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
adapter-node prebuilds its server source with rolldown into
files/and points the app's Vite build at that output. The only reason was to vendor devDependencies like sirv into the adapter, since a consumer'snode_modulescannot resolve them. With #16908 the source imports nothing but Node builtins,@sveltejs/kit/nodeand the hand-off module from #17103, all of which the app's own build resolves.This points the Vite inputs at
src/and deletes the prebuild: the rolldown config and dependency, the build scripts, the CI step that ran them, and the two test fixtures that guarded chunk patching and specifier interception, neither of which exists now.Stacked on #16908.