Skip to content

404 error page not working when navigating to an unknown route in Vercel with adapter-vercel #13518

@David-Hobson

Description

@David-Hobson

Describe the bug

With a SvelteKit app that is deployed to Vercel using adapter-vercel, any request to pages that are not found in routes will not render the +error.svelte page, but instead will throw a 500 error on the server. The expected behaviour would to show the +error.svelte page when navigating to an unknown route. The expected behaviour works with on a local environment and StackBlitz, but doesn't work when deployed to Vercel.

Reproduction

Main difference between the default SvelteKit template and this code is the use of adapter-vercel.

Repository: https://github.com/David-Hobson/sveltejs-kit-template-default-nfrbl1xj
StackBlitz: https://stackblitz.com/edit/sveltejs-kit-template-default-nfrbl1xj
Vercel Deployment: https://sveltejs-kit-template-default-git-2e6258-david-hobsons-projects.vercel.app/

Steps to Reproduce on Vercel:

  1. Navigate to https://sveltejs-kit-template-default-git-2e6258-david-hobsons-projects.vercel.app/ and see that a regular SvelteKit application is running in Vercel
  2. Navigate to https://sveltejs-kit-template-default-git-2e6258-david-hobsons-projects.vercel.app/foo and see a 500 error instead of the +error.svelte

Steps to Reproduce on StackBlitz

  1. Navigate to https://stackblitz.com/edit/sveltejs-kit-template-default-nfrbl1xj and see that a regular SvelteKit application is running in StackBlitz
  2. Within StackBlitz navigate to the /foo route and see that the +error.svelte page does render due to an unknown route.

Cloning the repo and running locally has the same behaviour as in StackBlitz, the issue occurs when deployed to Vercel.

Logs

Logs within Vercel when navigating to `/foo`

TypeError: manifest._.nodes[0] is not a function
    at respond_with_error (file:///var/task/.svelte-kit/output/server/index.js:1885:53)
    at resolve2 (file:///var/task/.svelte-kit/output/server/index.js:3029:22)
    at resolve (file:///var/task/.svelte-kit/output/server/index.js:2870:34)
    at init_promise.#options.hooks.handle (file:///var/task/.svelte-kit/output/server/index.js:3114:71)
    at respond (file:///var/task/.svelte-kit/output/server/index.js:2868:43)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)



StackBlitz and Local Logs (expected behaviour)

  VITE v6.2.0  ready in 2381 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
1:49:37 PM [vite] (client) ✨ new dependencies optimized: clsx
1:49:37 PM [vite] (client) ✨ optimized dependencies changed. reloading
SvelteKitError: Not found: /foo
    at new SvelteKitError (/home/projects/sveltejs-kit-template-default-nfrbl1xj/node_modules/@sveltejs/kit/src/runtime/control.js:10:3)
    at resolve (/home/projects/sveltejs-kit-template-default-nfrbl1xj/node_modules/@sveltejs/kit/src/runtime/server/respond.js:497:50)
    at resolve (/home/projects/sveltejs-kit-template-default-nfrbl1xj/node_modules/@sveltejs/kit/src/runtime/server/respond.js:308:23)
    at Object.eval (/home/projects/sveltejs-kit-template-default-nfrbl1xj/node_modules/@sveltejs/kit/src/runtime/server/index.js:39:34)
    at respond (/home/projects/sveltejs-kit-template-default-nfrbl1xj/node_modules/@sveltejs/kit/src/runtime/server/respond.js:306:31) {
  status: 404,
  text: 'Not Found'

System Info

System:
    OS: macOS 14.6
    CPU: (12) arm64 Apple M3 Pro
    Memory: 705.89 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.13.1 - ~/.nvm/versions/node/v22.13.1/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v22.13.1/bin/npm
    pnpm: 9.14.4 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 133.0.6943.142
    Edge: 133.0.3065.82
    Safari: 17.6
  npmPackages:
    @sveltejs/adapter-auto: ^4.0.0 => 4.0.0
    @sveltejs/adapter-vercel: ^5.6.3 => 5.6.3
    @sveltejs/kit: ^2.16.0 => 2.17.3
    @sveltejs/vite-plugin-svelte: ^5.0.0 => 5.0.3
    svelte: ^5.0.0 => 5.20.5
    vite: ^6.0.0 => 6.2.0

Severity

serious, but I can work around it

Additional Information

I have additionally opened an issue with Vercel to get more information as this could be an error on their end. Additionally tried this with adapter-auto as well which can be found here: https://github.com/David-Hobson/sveltejs-kit-template-default-nfrbl1xj/tree/use-adapter-auto which has resulted in the same issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions