sveltejs / sveltejs/kit

Adapter vercel split option breaks form action

Open
#12,291 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pkg:adapter-vercel
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Not sure if it might be related or not but I encounter another issue that happens in the exact same conditions.
Sadly I've been unable to find the time to create and deploy on Vercel a reproduction. Sorry if this is useless noise 🙏

Issue:

In a form action, I trigger an internal fetch call to a +server.ts route handler.
This route handler returns json data (return json({ ... })).
The route handler crashes with TypeError: immutable (full error below), and the action receives { message: 'Internal Error' }. Despite what the error message implies, I'm not trying to either set cookies or headers anywhere.

Conditions:
  • Only happens when deployed on Vercel
  • Only happens if the route handler is deployed separately (marked with split: true)
Error details
TypeError: immutable
    at _Headers.append (node:internal/deps/undici/undici:2105:17)
    at add_cookies_to_headers (file:///var/task/vercel/path0/apps/client/.svelte-kit/output/server/index.js:2320:13)
    at file:///var/task/vercel/path0/apps/client/.svelte-kit/output/server/index.js:2649:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async helpersHandle (file:///var/task/vercel/path0/apps/client/.svelte-kit/output/server/chunks/hooks.server.js:1181:18)
    at async respond (file:///var/task/vercel/path0/apps/client/.svelte-kit/output/server/index.js:2638:22)
    at async fetch (file:///var/task/vercel/path0/apps/client/.svelte-kit/output/server/index.js:2388:26)
Environment
    "@sveltejs/adapter-vercel": "3.1.0",
    "@sveltejs/kit": "1.30.4",
    "svelte": "4.2.12",

And Node.js 20.x on Vercel.

Originally posted by @benjaminwaterlot in https://github.com/sveltejs/kit/issues/11879#issuecomment-1971480386

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the stack trace in the generated .svelte-kit/output/server/index.js and hooks.server.js, then inspect the adapter-vercel path used when the route handler is deployed with split: true. Reproduce the Vercel deployment with the listed SvelteKit, adapter-vercel, Svelte, and Node.js versions; done means the form action's internal fetch receives the route handler's JSON response without the TypeError: immutable failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.