denoland/deno · error

invalid control sock

Error message

invalid control sock

What it means

cli/lib.rs:1268 is the catch-all arm of the DENO_UNSTABLE_CONTROL_SOCK parser: the value's scheme matched none of the supported transports (unix, tcp, vsock), so the whole address is rejected as "invalid control sock". It fires before any runtime work happens, at process bootstrap, and aborts startup.

Source

Thrown at cli/lib.rs:1268

      #[cfg(any(
        target_os = "android",
        target_os = "linux",
        target_os = "macos"
      ))]
      Some(("vsock", addr)) => {
        let Some((cid, port)) = addr.split_once(':') else {
          deno_core::anyhow::bail!("invalid vsock addr");
        };
        let cid = if cid == "-1" { u32::MAX } else { cid.parse()? };
        let port = port.parse()?;
        let addr = VsockAddr::new(cid, port);
        let listener = VsockListener::bind(addr)?;
        let (stream, _) = listener.accept().await?;
        let (rx, tx) = stream.into_split();
        (Box::new(rx), Box::new(tx))
      }
      _ => {
        deno_core::anyhow::bail!("invalid control sock");
      }
    };

    let mut buf = Vec::with_capacity(1024);
    BufReader::new(rx).read_until(b'\n', &mut buf).await?;

    tokio::spawn(async move {
      deno_runtime::deno_http::SERVE_NOTIFIER.notified().await;

      #[derive(deno_core::serde::Serialize)]
      enum Event {
        Serving {
          #[serde(skip_serializing_if = "Option::is_none")]
          kind: Option<&'static str>,
        },
      }

      let mut buf = deno_core::serde_json::to_vec(&Event::Serving {

View on GitHub (pinned to 89f33cbef2)

Solutions

  1. Use one of the supported transports: DENO_UNSTABLE_CONTROL_SOCK="unix:/abs/path" or "tcp:127.0.0.1:PORT" or "vsock:CID:PORT"
  2. Unset the variable (or scope it to the one service that needs it) if you did not intend a control socket at all: env -u DENO_UNSTABLE_CONTROL_SOCK deno run app.ts
  3. Grep your supervisor/unit files/CI env for the variable and align the scheme with the actual Deno version's supported list

Example fix

# before
DENO_UNSTABLE_CONTROL_SOCK=sock:/run/deno.sock deno run main.ts

# after
DENO_UNSTABLE_CONTROL_SOCK=unix:/run/deno.sock deno run main.ts
Defensive patterns

Strategy: validation

Validate before calling

#!/bin/sh
VAL="$DENO_UNSTABLE_CONTROL_SOCK"
case "$VAL" in
  unix:*|tcp:*|vsock:*) ;;  # supported schemes
  "") ;;                      # unset is fine
  *) echo "unsupported control sock: $VAL (expected unix:|tcp:|vsock:)"; exit 2 ;;
esac
exec deno run main.ts

Prevention

When it happens

Trigger: DENO_UNSTABLE_CONTROL_SOCK set to a value whose scheme is not recognized, e.g. "sock:/path", "vsock2:1:2", "unix2:/run/x", or a bare path "/run/deno.sock" with no scheme prefix.

Common situations: Environment variables leaking from another tool's config format (systemd socket units, Kubernetes dowward-api); typos in supervisor templates; leftover DENO_UNSTABLE_CONTROL_SOCK from experiments on machines where the intended transport name was misremembered.

Related errors


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