denoland/deno · error
Invalid serialization type: {}
Error message
Invalid serialization type: {} What it means
At startup Deno reads NODE_CHANNEL_SERIALIZATION_MODE (the env var Node uses for child_process IPC serialization) and parses it with FromStr, which accepts only the exact strings `json` and `advanced`; anything else fails startup with this message. The parse runs whenever the variable is present, even if NODE_CHANNEL_FD is unset.
Source
Thrown at ext/node/ops/ipc.rs:17
// Copyright 2018-2026 the Deno authors. MIT license.
pub use impl_::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ChildIpcSerialization {
Json,
Advanced,
}
impl std::str::FromStr for ChildIpcSerialization {
type Err = deno_core::anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"json" => Ok(ChildIpcSerialization::Json),
"advanced" => Ok(ChildIpcSerialization::Advanced),
_ => Err(deno_core::anyhow::anyhow!(
"Invalid serialization type: {}",
s
)),
}
}
}
pub struct ChildPipeFd(pub i64, pub ChildIpcSerialization);
mod impl_ {
use std::cell::RefCell;
use std::future::Future;
use std::io;
use std::rc::Rc;
use deno_core::CancelFuture;
use deno_core::OpState;
use deno_core::RcRef;View on GitHub (pinned to 89f33cbef2)
Solutions
- Set NODE_CHANNEL_SERIALIZATION_MODE to exactly `json` or `advanced` (lowercase) in the parent process
- Strip the variable when it is not meant for Deno: `env -u NODE_CHANNEL_SERIALIZATION_MODE deno run main.ts`
- Audit shell profiles, Dockerfile ENV lines and CI env blocks for stray NODE_CHANNEL_* exports
Example fix
# before — startup fails: Invalid serialization type: JSON NODE_CHANNEL_SERIALIZATION_MODE=JSON deno run main.ts # after — exact lowercase value NODE_CHANNEL_SERIALIZATION_MODE=json deno run main.ts
Defensive patterns
Strategy: validation
Validate before calling
# validate before invoking deno
case "${NODE_CHANNEL_SERIALIZATION_MODE:-}" in
""|json|advanced) ;;
*) echo "bad NODE_CHANNEL_SERIALIZATION_MODE: '$NODE_CHANNEL_SERIALIZATION_MODE'"; exit 1;;
esac
deno run main.ts Type guard
fn is_valid_serialization(s: &str) -> bool {
matches!(s, "json" | "advanced")
} Prevention
- Never export NODE_CHANNEL_* globally; scope them to the child spawn that needs them
- When spawning Deno children over IPC, pass exactly `json` or `advanced` (lowercase)
- In wrappers, strip NODE_CHANNEL_SERIALIZATION_MODE with `env -u` when Deno is not the IPC target
When it happens
Trigger: Launching any `deno` command with NODE_CHANNEL_SERIALIZATION_MODE exported as a value other than json or advanced — different casing (`JSON`), trailing characters, or invented values like `v8`.
Common situations: Deno spawned as a child of npm/pnpm script runners or test harnesses that export NODE_CHANNEL_* variables; leftover env exports in a shell profile or Dockerfile from a Node debug session; CI images that pre-set these vars globally.
Related errors
- ERR_CHILD_PROCESS_IPC_REQUIRED
- ERR_INVALID_ARG_TYPE
- Failed to read env var OTEL_EXPORTER_OTLP_PROTOCOL: {}
- Expected 'fn' field in the first argument to be a bench func
- Unsupported 'alpnProtocols' option provided. 'h2' and 'http/
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/af91e3a0d29070b0.
Report an issue: GitHub.