{"record":{"id":"1aebd5d765dbac32","repo":"sveltejs/kit","slug":"invalid-data-for-set-reviver","errorCode":null,"errorMessage":"Invalid data for Set reviver","messagePattern":"Invalid data for Set reviver","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/shared.js","lineNumber":205,"sourceCode":"\t\t\tfor (const item of value) {\n\t\t\t\tif (\n\t\t\t\t\t!Array.isArray(item) ||\n\t\t\t\t\titem.length !== 2 ||\n\t\t\t\t\ttypeof item[0] !== 'string' ||\n\t\t\t\t\ttypeof item[1] !== 'string'\n\t\t\t\t) {\n\t\t\t\t\tthrow new Error('Invalid data for Map reviver');\n\t\t\t\t}\n\t\t\t\tconst [key, val] = item;\n\t\t\t\tmap.set(parse(key), parse(val));\n\t\t\t}\n\n\t\t\treturn map;\n\t\t},\n\t\t/** @type {(value: unknown) => Set<unknown>} */\n\t\t[remote_set]: (value) => {\n\t\t\tif (!Array.isArray(value)) {\n\t\t\t\tthrow new Error('Invalid data for Set reviver');\n\t\t\t}\n\n\t\t\tconst set = new Set();\n\n\t\t\tfor (const item of value) {\n\t\t\t\tif (typeof item !== 'string') {\n\t\t\t\t\tthrow new Error('Invalid data for Set reviver');\n\t\t\t\t}\n\t\t\t\tset.add(parse(item));\n\t\t\t}\n\n\t\t\treturn set;\n\t\t},\n\t\t/** @type {(value: any) => File} */\n\t\t[remote_file]: (value) => {\n\t\t\tif (\n\t\t\t\t!value ||\n\t\t\t\ttypeof value !== 'object' ||","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/shared.js#L187-L223","documentation":"SvelteKit remote functions serialize arguments with devalue and revive them on the receiving side. The Set reviver expects the encoded payload for a Set to be a plain array of devalue-encoded strings. When the payload is not an array, Kit throws this error rather than producing a corrupt Set.","triggerScenarios":"Calling a remote function whose argument (or nested value) is a Set, but the serialized payload reaching create_remote_arg_revivers' [remote_set] reviver is not an array — typically because the encoded string was produced by a mismatched Kit version, hand-crafted/tampered, or corrupted in transit (e.g. truncated query param or POST body).","commonSituations":"Version skew between @sveltejs/kit packages during upgrades (old client code against new server code or vice versa); manually editing or caching an encoded remote-arg URL; proxies or middleware rewriting request payloads.","solutions":["Reinstall/upgrade @sveltejs/kit so client and server run the same version (pnpm install, clear node_modules/.vite cache)","Clear cached prerendered files and dev caches that may hold stale encoded payloads (.svelte-kit, build output)","Check that middleware/proxies do not alter remote-function request bodies or query strings","Reproduce with a minimal Set argument; if a specific element triggers it, file a bug with the payload"],"exampleFix":"// before (stale versions)\n\"@sveltejs/kit\": \"2.0.0\", \"@sveltejs/vite-plugin-svelte\": \"^5\"\n// after (aligned)\n\"@sveltejs/kit\": \"^2.22.0\", \"@sveltejs/vite-plugin-svelte\": \"^5.0.0\"","handlingStrategy":"validation","validationCode":"const isEncodedSet = (v) => Array.isArray(v) && v.length === 0 || (Array.isArray(v) && v.every((i) => typeof i === 'string'));\nif (!isEncodedSet(payload)) throw new Error('Refusing to revive malformed Set payload');","typeGuard":"function isValidRemoteSetPayload(v) {\n  return Array.isArray(v) && v.every((i) => typeof i === 'string');\n}","tryCatchPattern":"try {\n  const result = await myRemoteFn(mySet);\n} catch (e) {\n  if (e.message.includes('Invalid data for Set reviver')) {\n    console.error('Remote Set payload corrupted — check Kit versions and request integrity');\n  } else throw e;\n}","preventionTips":["Keep @sveltejs/kit versions identical across packages in the repo","Don't hand-craft or mutate remote-function request payloads","Purge CDN/caches after upgrading Kit","Test remote functions with Set/Map/File arguments after every upgrade"],"tags":["serialization","remote-functions","devalue"],"backgroundTag":"invalid-serialized-remote-argument","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}