{"record":{"id":"af91e3a0d29070b0","repo":"denoland/deno","slug":"invalid-serialization-type","errorCode":null,"errorMessage":"Invalid serialization type: {}","messagePattern":"Invalid serialization type: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ext/node/ops/ipc.rs","lineNumber":17,"sourceCode":"// Copyright 2018-2026 the Deno authors. MIT license.\n\npub use impl_::*;\n\n#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]\npub enum ChildIpcSerialization {\n  Json,\n  Advanced,\n}\n\nimpl std::str::FromStr for ChildIpcSerialization {\n  type Err = deno_core::anyhow::Error;\n  fn from_str(s: &str) -> Result<Self, Self::Err> {\n    match s {\n      \"json\" => Ok(ChildIpcSerialization::Json),\n      \"advanced\" => Ok(ChildIpcSerialization::Advanced),\n      _ => Err(deno_core::anyhow::anyhow!(\n        \"Invalid serialization type: {}\",\n        s\n      )),\n    }\n  }\n}\n\npub struct ChildPipeFd(pub i64, pub ChildIpcSerialization);\n\nmod impl_ {\n  use std::cell::RefCell;\n  use std::future::Future;\n  use std::io;\n  use std::rc::Rc;\n\n  use deno_core::CancelFuture;\n  use deno_core::OpState;\n  use deno_core::RcRef;","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/ops/ipc.rs#L1-L35","documentation":"When a Deno process starts with NODE_CHANNEL_FD set — how node:child_process.fork() wires the IPC channel to the child — it also reads NODE_CHANNEL_SERIALIZATION_MODE and parses it into ChildIpcSerialization, which accepts exactly \"json\" or \"advanced\" (FromStr in ext/node/ops/ipc.rs:11-23, wired from cli/lib/args.rs:56-68). Any other string aborts startup with \"Invalid serialization type: {s}\". fork() itself validates the option, so this almost always comes from hand-rolled spawns that set the env vars directly.","triggerScenarios":"Spawning deno manually with NODE_CHANNEL_FD=3 and NODE_CHANNEL_SERIALIZATION_MODE=JSON (wrong case), or values like ini/v8/serialize; forwarding an unvalidated serialization setting from a parent tool to a Deno child meant to speak process.send().","commonSituations":"Replacing a Node child with a Deno child in an existing fork harness; test runners that emulate fork via env; documentation examples that set the var with the wrong casing or a Node-internal name.","solutions":["Use one of the two accepted lowercase values: NODE_CHANNEL_SERIALIZATION_MODE=json or =advanced.","If the child should not have IPC at all, unset both NODE_CHANNEL_FD and NODE_CHANNEL_SERIALIZATION_MODE in the spawn env.","Prefer node:child_process.fork() from a Node/Deno parent — it sets the env correctly and validates the option for you."],"exampleFix":"// before\nspawn('deno', ['child.ts'], {\n  env: { ...process.env, NODE_CHANNEL_FD: '3', NODE_CHANNEL_SERIALIZATION_MODE: 'JSON' },\n});\n// child dies at startup: Invalid serialization type: JSON\n\n// after\nspawn('deno', ['child.ts'], {\n  env: { ...process.env, NODE_CHANNEL_FD: '3', NODE_CHANNEL_SERIALIZATION_MODE: 'json' },\n});","handlingStrategy":"type-guard","validationCode":"// Validate the env before spawning a Deno child with an IPC channel\nconst modes = new Set([\"json\", \"advanced\"]);\nconst mode = process.env.NODE_CHANNEL_SERIALIZATION_MODE;\nif (process.env.NODE_CHANNEL_FD && (mode !== undefined) && !modes.has(mode)) {\n  throw new Error(`NODE_CHANNEL_SERIALIZATION_MODE must be json|advanced, got ${mode}`);\n}","typeGuard":"type IpcSerialization = \"json\" | \"advanced\";\nconst isIpcSerialization = (v: string): v is IpcSerialization =>\n  v === \"json\" || v === \"advanced\";","tryCatchPattern":null,"preventionTips":["Use exactly lowercase json or advanced — the value is case-sensitive.","Unset both NODE_CHANNEL_FD and NODE_CHANNEL_SERIALIZATION_MODE when the child should have no IPC.","Prefer node:child_process.fork() over hand-setting these env vars; it validates the option for you."],"tags":["node-compat","ipc","child-process","env"],"backgroundTag":"invalid-env-var-value","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}