{"record":{"id":"e1301de006a7f5be","repo":"sveltejs/kit","slug":"called-uneval-before-init-transport","errorCode":null,"errorMessage":"called uneval before init_transport","messagePattern":"called uneval before init_transport","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/app/internal/transport.js","lineNumber":7,"sourceCode":"/** @import { Transport } from '@sveltejs/kit/hooks' */\nimport * as devalue from 'devalue';\nimport { DEV } from 'esm-env';\n\n/** @type {(thing: any) => string} */\nexport let uneval = () => {\n\tthrow new Error(DEV ? 'called uneval before init_transport' : '');\n};\n\n/** @type {(data: any) => string} */\nexport let stringify = () => {\n\tthrow new Error(DEV ? 'called stringify before init_transport' : '');\n};\n\n/** @type {(data: string) => any} */\nexport let parse = () => {\n\tthrow new Error(DEV ? 'called parse before init_transport' : '');\n};\n\n/** @type {Record<string, (data: any) => any>} */\nexport let encoders = {};\n\n/** @type {Record<string, (data: any) => any>} */\nexport let decoders = {};\n","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/app/internal/transport.js#L1-L25","documentation":"uneval is a stub that SvelteKit replaces via init_transport when the server rendering pipeline initializes the devalue transport. If code calls uneval before that initialization, the stub throws in dev (and throws a blank error in prod). It signals an out-of-order or out-of-context call of an internal serialization hook.","triggerScenarios":"Calling the exported uneval from @sveltejs/kit (or reaching this module) before init_transport has run — typically custom server code or a plugin invoking server-side serialization outside a request render handled by SvelteKit.","commonSituations":"Calling transport/uneval utilities from adapter hooks or custom server entry points before kit initializes, importing internals directly, or tests invoking uneval without setting up kit's render pipeline.","solutions":["Call uneval only within the request lifecycle managed by SvelteKit (e.g. inside load or server hooks), not in server bootstrap code","Use `devalue.stringify`/`uneval` from the devalue package directly if you need standalone serialization","If you maintain an adapter, ensure init_transport is invoked before rendering","Update @sveltejs/kit; this internal API changed with the transport refactor"],"exampleFix":"// before\nimport { uneval } from '@sveltejs/kit/internal'; // outside render\n// after\nimport { stringify } from 'devalue';\nconst s = stringify(data);","handlingStrategy":"try-catch","validationCode":"import { uneval } from 'your-transport-module';\nif (typeof uneval.__initialized !== 'boolean') {\n  throw new Error('transport not initialized: call init_transport first');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const js = uneval(data);\n} catch (e) {\n  if (e.message === 'called uneval before init_transport') {\n    // serialize outside kit with devalue instead\n  } else throw e;\n}","preventionTips":["Only call kit transport helpers inside the kit request lifecycle","Use the devalue package directly for standalone serialization","Initialize transport (init_transport) before any custom rendering that serializes data","Avoid importing kit internal transport modules directly"],"tags":["serialization","devalue","transport","initialization-order"],"backgroundTag":"called-before-init-transport","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}