Skip to content

Introduce of custom transports leads to deserialize not working on server side #13675

@gurpreetatwal

Description

@gurpreetatwal

Describe the bug

Prior to @sveltejs/kit@2.11.0 I was able to use the deserialize function in server side routes to parse the response returned by calling svelte kit action methods using fetch. If relevant, my specific use case is a route that runs automates filling out some forms for the user based on the response from an LLM. I use deserialize to parse the response from the action.

Attempting to upgrade to any version >= 2.11.0 (including latest 2.20.3 as of April 3) results in all server side usages of deserialize throwing the following error:

Cannot read properties of undefined (reading 'decoders')
TypeError: Cannot read properties of undefined (reading 'decoders')
    at deserialize (/node_modules/@sveltejs/kit/src/runtime/app/forms.js:37:84)
    at load (/src/routes/load/+page.server.js:17:74)
    at async load_server_data (/node_modules/@sveltejs/kit/src/runtime/server/page/load_data.js:45:18)
    at async Promise.all (index 1)
    at async render_data (/node_modules/@sveltejs/kit/src/runtime/server/data/index.js:101:17)
    at async resolve (/node_modules/@sveltejs/kit/src/runtime/server/respond.js:443:17)
    at async respond (/node_modules/@sveltejs/kit/src/runtime/server/respond.js:329:20)
    at async file:///node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:521:22

I ran npm run build and npm run preview results in the same error as well.

deserialize still works when used client side (.svelte) files but does not work in any server.js/ts files.

Reproduction

Logs

Cannot read properties of undefined (reading 'decoders')
TypeError: Cannot read properties of undefined (reading 'decoders')
    at deserialize (/node_modules/@sveltejs/kit/src/runtime/app/forms.js:37:84)
    at load (/src/routes/load/+page.server.js:17:74)
    at async load_server_data (/node_modules/@sveltejs/kit/src/runtime/server/page/load_data.js:45:18)
    at async Promise.all (index 1)
    at async render_data (/node_modules/@sveltejs/kit/src/runtime/server/data/index.js:101:17)
    at async resolve (/node_modules/@sveltejs/kit/src/runtime/server/respond.js:443:17)
    at async respond (/node_modules/@sveltejs/kit/src/runtime/server/respond.js:329:20)
    at async file:///node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:521:22

Cannot read properties of undefined (reading 'decoders')
TypeError: Cannot read properties of undefined (reading 'decoders')
    at deserialize (file:///.svelte-kit/output/server/chunks/forms.js:6:50)
    at load (file:///.svelte-kit/output/server/entries/pages/load/_page.server.js:12:37)
    at async load_server_data (file:///.svelte-kit/output/server/index.js:621:18)
    at async Promise.all (index 1)
    at async render_data (file:///.svelte-kit/output/server/index.js:1965:19)
    at async resolve2 (file:///.svelte-kit/output/server/index.js:2977:22)
    at async respond (file:///.svelte-kit/output/server/index.js:2882:22)
    at async file:///node_modules/@sveltejs/kit/src/exports/vite/preview/index.js:197:5

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
    Memory: 11.96 GB / 31.28 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 22.13.1 - ~/.local/share/nodejs/bin/node
    Yarn: 1.22.22 - ~/.local/share/nodejs/bin/yarn
    npm: 10.9.2 - ~/.local/share/nodejs/bin/npm
    pnpm: 9.1.0 - ~/.local/share/nodejs/bin/pnpm
  Browsers:
    Chrome: 135.0.7049.52
  npmPackages:
    @sveltejs/adapter-node: ^5.2.12 => 5.2.12
    @sveltejs/kit: ^2.10.0 => 2.10.0
    @sveltejs/vite-plugin-svelte: ^3.1.2 => 3.1.2
    svelte: ^4.2.19 => 4.2.19
    vite: ^5.4.10 => 5.4.11

Severity

blocking an upgrade

Additional Information

Probably related to #13149

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