denoland/deno · error
invalid vsock port
Error message
invalid vsock port
What it means
For a vsock cron socket address (DENO_UNSTABLE_CRON_SOCK='vsock:cid:port'), the port segment is parsed into the u32 that tokio_vsock's VsockAddr::new expects. Any port that does not parse as u32 returns io::ErrorKind::InvalidInput 'invalid vsock port'. Note this is a vsock service port, not an IP port, so values above 65535 are legal up to u32::MAX.
Source
Thrown at ext/cron/socket.rs:395
use tokio_vsock::VsockStream;
let (cid, port) = addr.split_once(':').ok_or_else(|| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"invalid vsock addr",
)
})?;
let cid = if cid == "-1" {
u32::MAX
} else {
cid.parse().map_err(|_| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"invalid vsock cid",
)
})?
};
let port = port.parse().map_err(|_| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"invalid vsock port",
)
})?;
let stream = tokio::time::timeout(
std::time::Duration::from_secs(5),
VsockStream::connect(VsockAddr::new(cid, port)),
)
.await??;
Ok(SocketStream::Vsock(stream))
}
_ => Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"invalid socket address",
)),
}
}
View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Use a plain decimal port: DENO_UNSTABLE_CRON_SOCK='vsock:3:5000'
- Strip whitespace/newlines from the variable before launching Deno
- Double-check copy-pasted addresses for a missing or doubled port segment
Example fix
# before DENO_UNSTABLE_CRON_SOCK='vsock:3:0x1388' deno run app.ts # Error: invalid vsock port # after DENO_UNSTABLE_CRON_SOCK='vsock:3:5000' deno run app.ts
Defensive patterns
Strategy: validation
Validate before calling
const addr = Deno.env.get('DENO_UNSTABLE_CRON_SOCK')?.trim() ?? '';
if (addr.startsWith('vsock:')) {
const port = addr.split(':')[2];
if (!/^\d{1,10}$/.test(port) || Number(port) > 0xFFFFFFFF) {
throw new Error(`Invalid vsock port in '${addr}'; expected decimal u32`);
}
} Prevention
- Use decimal vsock service ports (u32); do not assume the TCP 16-bit limit
- Trim the env var value before use
- Lint CI configuration that sets DENO_UNSTABLE_CRON_SOCK against the vsock:cid:port shape
When it happens
Trigger: DENO_UNSTABLE_CRON_SOCK='vsock:3:abc' (non-numeric), 'vsock:3:5000.5' (float), 'vsock:3:' (empty port after the second colon), a port above 4294967295, or trailing whitespace/newline in the env var value ('vsock:3:5000 ' fails the parse).
Common situations: VM sandbox environments syncing cron over AF_VSOCK; operators assuming TCP port limits and writing hex/octal; CI secrets injecting the address with a trailing newline.
Related errors
- invalid vsock cid
- invalid socket address
- Can't convert url ("{}") to filename.
- Can't convert url ("{}") to filename.
- Invalid port (expected number): ${maybePort}
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/65ffffffaec83206.
Report an issue: GitHub.