Skip to content

404s cause tremendous performance drops on latest SvelteKit dev server #13734

Closed

Description

@Algoinde

Describe the bug

Pretty simple: create the most barebones empty project, put 50 image tags with random root paths. When they 404 against SvelteKit's handling logic, you can observe the following, in all environments (different node versions, WSL, powershell, stackblitz):

Image

I believe there's some kind of a performance bottleneck in request handling logic.

While I was developing with data present, but assets missing, I had serial 404s (20-30 requests at reload) which completely pegged my CPU and caused the browser to stall.

I tested on my old SvelteKit 1 project (1.30.4) and this also happens there.

This does not happen in production build using adapter-node, this only affects the dev server.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-xyultybt?file=src%2Froutes%2F%2Blayout.svelte
(look at worker timings for 404s)

Logs

SvelteKitError: Not found: /asd2323323dad.png
    at resolve2 (file:///C:/Projects/my-app/.svelte-kit/output/server/index.js:3208:18)
    at file:///C:/Projects/my-app/.svelte-kit/output/server/index.js:3030:19
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at with_event (file:///C:/Projects/my-app/.svelte-kit/output/server/index.js:63:22)
    at resolve (file:///C:/Projects/my-app/.svelte-kit/output/server/index.js:3028:11)
    at init_promise.#options.hooks.handle (file:///C:/Projects/my-app/.svelte-kit/output/server/index.js:3294:71) 
    at file:///C:/Projects/my-app/.svelte-kit/output/server/index.js:3023:28
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at with_event (file:///C:/Projects/my-app/.svelte-kit/output/server/index.js:63:22)
    at respond (file:///C:/Projects/my-app/.svelte-kit/output/server/index.js:3021:28) {
  status: 404,
  text: 'Not Found'
}

System Info

System:
    OS: Windows 11 10.0.22000
    CPU: (12) x64 AMD Ryzen 5 3600X 6-Core Processor
    Memory: 44.28 GB / 63.95 GB
  Binaries:
    Node: 20.16.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (130.0.2849.68)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    @sveltejs/adapter-auto: ^4.0.0 => 4.0.0
    @sveltejs/kit: ^2.16.0 => 2.20.7
    @sveltejs/vite-plugin-svelte: ^5.0.0 => 5.0.3
    svelte: ^5.0.0 => 5.28.2
    vite: ^6.2.5 => 6.3.2

Severity

serious, but I can work around it

Additional Information

No response

Activity

  1. Nic-Polumeyv commented on Jul 21, 2026

    @Nic-Polumeyv
    Member

    The cost is the error page render, not the 404. Each unmatched subresource request SSRs the root layout + error page; in dev that adds Vite module fetching, style dep walking and ssrFixStacktrace on a stack the default handleError then discards. ~13ms server CPU per 404 vs ~4ms for a static file hit on Linux, worse on Windows, and browsers fire dozens in parallel.

    Since Safari 16.4 all browsers send Sec-Fetch-Dest, so we can skip the render for destinations that can never display HTML. Next.js is doing the same in vercel/next.js#95930.

  2. added a commit that references this issue on Jul 21, 2026
    c99a6cf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions