{"record":{"id":"46f7daf07aaf4e96","repo":"denoland/deno","slug":"udp-socket-ipc-handle-passing-is-not-supported-on","errorCode":null,"errorMessage":"UDP socket IPC handle passing is not supported on this platform","messagePattern":"UDP socket IPC handle passing is not supported on this platform","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ext/node/ops/udp.rs","lineNumber":694,"sourceCode":"  #[cfg(unix)]\n  {\n    use std::os::unix::io::FromRawFd;\n    // SAFETY: The fd was received via SCM_RIGHTS and is a valid, open socket.\n    let std_socket = unsafe { std::net::UdpSocket::from_raw_fd(fd) };\n    std_socket.set_nonblocking(true)?;\n    let local_addr = std_socket.local_addr()?;\n    let socket = UdpSocket::from_std(std_socket)?;\n    let resource = NodeUdpSocketResource {\n      socket,\n      cancel: Default::default(),\n    };\n    let rid = state.resource_table.add(resource);\n    Ok((rid, local_addr.ip().to_string(), local_addr.port()))\n  }\n  #[cfg(not(unix))]\n  {\n    let _ = (state, fd);\n    Err(NodeUdpError::Io(std::io::Error::new(\n      std::io::ErrorKind::Unsupported,\n      \"UDP socket IPC handle passing is not supported on this platform\",\n    )))\n  }\n}\n","sourceCodeStart":676,"sourceCodeEnd":700,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/ops/udp.rs#L676-L700","documentation":"Deno's node-compat op that adopts a UDP socket received over the Node IPC channel (fd passed from a parent process, e.g. via cluster or child_process) is only implemented for Unix. The #[cfg(not(unix))] branch returns ErrorKind::Unsupported with this message, so on Windows a bound UDP socket cannot be handed to a child through IPC.","triggerScenarios":"Using node:cluster on Windows where the primary passes a dgram socket to a worker, or child_process with an IPC channel that tries to transfer a UDP socket handle to the child on Windows. The op receives the fd over the channel and immediately fails because handle adoption is Unix-only.","commonSituations":"Code that works on Linux/macOS CI fails when run or deployed on Windows; cross-platform test matrices; npm packages that rely on cluster+dgram (e.g. some metric collectors).","solutions":["Do not pass UDP sockets over IPC on Windows; bind a fresh socket in the child and send only configuration (port, multicast membership) over the channel.","Gate the feature: if (process.platform === 'win32') use a fallback path that creates the socket in each worker with SO_REUSEADDR.","Run the workload in a Linux container when the handle-passing behavior is required."],"exampleFix":"// before (primary)\nworker.send({ cmd: 'bind' }, udpSocket); // fails on Windows: UDP socket IPC handle passing is not supported\n\n// after\nif (process.platform === 'win32') {\n  worker.send({ cmd: 'bind', port: 54321 }); // child binds its own socket\n} else {\n  worker.send({ cmd: 'bind' }, udpSocket);\n}","handlingStrategy":"validation","validationCode":"const canPassUdpOverIpc = process.platform !== \"win32\";\nif (!canPassUdpOverIpc) worker.send({ cmd: \"bind\", port }); else worker.send({ cmd: \"bind\" }, udpSocket);","typeGuard":"const supportsUdpIpc = (p: NodeJS.Platform): p is \"linux\" | \"darwin\" | \"freebsd\" => p !== \"win32\";","tryCatchPattern":"try { child.send(msg, udpSocket); } catch (e) { if (/not supported on this platform/.test(String(e))) child.send({ ...msg, bindYourself: true }); else throw e; }","preventionTips":["Design IPC protocols so children can create their own sockets from config instead of receiving handles.","Test cluster/dgram code on Windows in CI, not only Linux/macOS.","Feature-detect by process.platform before using handle-passing APIs."],"tags":["udp","ipc","windows","cluster","platform-unsupported","node-compat"],"backgroundTag":"unsupported-platform","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}