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

  1. Set NODE_CHANNEL_SERIALIZATION_MODE to exactly `json` or `advanced` (lowercase) in the parent process
  2. Strip the variable when it is not meant for Deno: `env -u NODE_CHANNEL_SERIALIZATION_MODE deno run main.ts`
  3. 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

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


AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16). Data as JSON: /api/errors/af91e3a0d29070b0. Report an issue: GitHub.