sveltejs/kit · error · Error

called parse before init_transport

Error message

called parse before init_transport

What it means

parse is a stub that init_transport replaces with the real devalue-backed parser once the client runtime initializes the transport. Calling it before initialization throws in dev. It indicates the deserialization API is being used before kit's client bootstrap wires up the encoders.

Source

Thrown at packages/kit/src/runtime/app/internal/transport.js:17

/** @import { Transport } from '@sveltejs/kit/hooks' */
import * as devalue from 'devalue';
import { DEV } from 'esm-env';

/** @type {(thing: any) => string} */
export let uneval = () => {
	throw new Error(DEV ? 'called uneval before init_transport' : '');
};

/** @type {(data: any) => string} */
export let stringify = () => {
	throw new Error(DEV ? 'called stringify before init_transport' : '');
};

/** @type {(data: string) => any} */
export let parse = () => {
	throw new Error(DEV ? 'called parse before init_transport' : '');
};

/** @type {Record<string, (data: any) => any>} */
export let encoders = {};

/** @type {Record<string, (data: any) => any>} */
export let decoders = {};

export let has_custom_transporters = false;

/**
 *
 * @param {Transport} transport
 */
export function init_transport(transport) {
	const transporters = Object.entries(transport);

	has_custom_transporters = transporters.length > 0;

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Let SvelteKit parse transport data (use the deserialized results in load/​form actions rather than calling parse yourself)
  2. Use `devalue.parse` directly with the proper revivers if you need standalone parsing
  3. Ensure whatever harness/test boots the app loads kit's client entry (which calls init_transport)
  4. Update @sveltejs/kit to the latest version

Example fix

// before
import { parse } from '@sveltejs/kit/internal';
// after
import { parse } from 'devalue';
Defensive patterns

Strategy: try-catch

Validate before calling

import { parse } from 'your-transport-module';
if (typeof parse.__initialized !== 'boolean') {
  throw new Error('client transport not initialized');
}

Try / catch

try {
  const data = parse(payload);
} catch (e) {
  if (e.message === 'called parse before init_transport') {
    // wait for client bootstrap or use devalue.parse with revivers
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the exported parse before init_transport runs on the client — e.g. custom client code or tests importing the transport internals directly and parsing transport payloads before kit bootstraps.

Common situations: Manually parsing `__sveltekit` transport payloads in custom scripts or extensions, unit tests that skip kit's client entry, or older adapters/custom render paths that bypass initialization.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/692b49cdbf5a881c. Report an issue: GitHub.