adapter-node@5.5.5: `node build` returns 404 for all `/_app/*` and static client assets (broken import.meta.url asset dir from #16069)
pkg:adapter-nodep1-important
### Describe the bug
Since `@sveltejs/adapter-node@5.5.5`, the `node build` server boots fine but returns **404 for every hashed `/_app/immutable/*` bundle and every static client file** (e.g. `static/robots.txt`, `service-worker.js`). The SSR shell renders (`GET /` → 200) but no client JS or asset loads, so the app appears up yet is unusable (e.g. a login page with no working JS). `5.5.4` serves them correctly. `vite preview` is unaffected — this is `node build` only.
### Reproduction (clean official scaffold, zero custom code)
```bash
npx sv create app --template minimal --types ts --no-add-ons
cd app
# vite.config.ts: import adapter from '@sveltejs/adapter-auto' -> '@sveltejs/adapter-node'
# (classic layout: same change in svelte.config.js)
npm i -D @sveltejs/adapter-node@5.5.5
npm run build
PORT=3000 ORIGIN=http://localhost:3000 node build &
curl -o /dev/null -w '%{http_code}\n' http://localhost:3000/robots.txt # 404 (200 on 5.5.4)
curl -o /dev/null -w '%{http_code}\n' "http://localhost:3000/_app/immutable/entry/$(ls build/client/_app/immutable/entry | head -1)" # 404 (200 on 5.5.4)
```
Verified on `@sveltejs/kit@2.65.2`, `vite@8.0.16`, node 26 — and independently on kit 2.66 / vite 6.4.3. Downgrading **only** the adapter to `5.5.4` fixes it.
### Root cause
[#16069](https://github.com/sveltejs/kit/pull/16069) ("bundle entrypoints alongside app code") makes Rollup hoist the handler implementation into a shared chunk under `build/server/chunks/` — both `build/index.js` and `build/handler.js` become facades re-exporting from it (`export { h as handler } from './server/chunks/CEnvyx7R-….js'`). The handler computes:
```js
const dir = path.dirname(fileURLToPath(import.meta.url));
const asset_dir = `${dir}/client${BASE}`;
// ...
([serve(path.join(dir, 'client'), true), serve_prerendered(), ssr])
```
With that code now executing from `build/server/chunks/…js`, `dir` resolves to `build/server/chunks/` instead of `build/`. `serve(path.join(dir, 'client'))` looks for `build/server/chunks/client` (does not exist) → `serve()` returns `undefined` and is filtered out → all requests fall through to SSR (404 / SSR-redirect). On `5.5.4` the handler stays inlined at `build/handler.js` (`export { handler };`), so `dir` = `build/` and assets serve.
This is the same #16069 mechanism likely behind #16087, #16090 and #16092.
### System Info
- `@sveltejs/adapter-node`: **5.5.5** (regression vs 5.5.4)
- `@sveltejs/kit`: 2.65.2 / 2.66.0
- `vite`: 8.0.16 / 6.4.3
- Node 26, macOS
1 条评论