{"record":{"id":"9c34a43e4782c6a2","repo":"astrid-runtime/astrid","slug":"windows-named-pipe-endpoint-is-occupied-but-unavai","errorCode":null,"errorMessage":"Windows named-pipe endpoint is occupied but unavailable","messagePattern":"Windows named-pipe endpoint is occupied but unavailable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-core/src/local_transport/windows.rs","lineNumber":338,"sourceCode":"}\n\npub(super) fn split(\n    stream: LocalStream,\n) -> (\n    tokio::io::ReadHalf<LocalStream>,\n    tokio::io::WriteHalf<LocalStream>,\n) {\n    tokio::io::split(stream)\n}\n\npub(super) fn probe(path: &Path) -> io::Result<()> {\n    match endpoint_state(path)? {\n        EndpointState::Available => Ok(()),\n        EndpointState::Absent => Err(io::Error::new(\n            io::ErrorKind::NotFound,\n            \"Windows named-pipe endpoint is absent\",\n        )),\n        EndpointState::BusyOrDenied => Err(io::Error::new(\n            io::ErrorKind::WouldBlock,\n            \"Windows named-pipe endpoint is occupied but unavailable\",\n        )),\n    }\n}\n\npub(super) fn endpoint_is_present(path: &Path) -> io::Result<bool> {\n    Ok(!matches!(endpoint_state(path)?, EndpointState::Absent))\n}\n\npub(super) fn remove_endpoint(path: &Path) -> io::Result<()> {\n    if endpoint_is_present(path)? {\n        return Err(io::Error::new(\n            io::ErrorKind::PermissionDenied,\n            \"Windows named-pipe endpoints are kernel-owned and cannot be removed while live\",\n        ));\n    }\n    Ok(())","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-core/src/local_transport/windows.rs#L320-L356","documentation":"probe() reports EndpointState::BusyOrDenied as io::ErrorKind::WouldBlock with this message: the named pipe exists, but it is occupied (all instances busy, ERROR_PIPE_BUSY) or access is denied, so a connection attempt cannot proceed right now. Unlike the Absent case, retrying later may succeed once the server frees a pipe instance.","triggerScenarios":"Calling probe(path) when the pipe's instance count is exhausted (all instances connected) or the pipe ACL denies the probing client (ERROR_ACCESS_DENIED), i.e. endpoint_state returns BusyOrDenied.","commonSituations":"More clients than the server's pipe instance limit (default CreateNamedPipe instance count of 1) are trying to connect concurrently; long-lived connections exhaust the server's instances; ACL mismatch between client and server accounts.","solutions":["Retry with backoff, or use the client's open_with_retry path which waits for pipe availability on ERROR_PIPE_BUSY","Increase the server's named-pipe instance count when creating the pipe (nMaxInstances) so concurrent clients can connect","If it is denial rather than busy, align the client's account with the pipe ACL (see PermissionDenied handling)"],"exampleFix":"// before\nprobe(&pipe_path)?; // WouldBlock when busy\n// after\nloop {\n    match probe(&pipe_path) {\n        Ok(()) => break,\n        Err(e) if e.kind() == io::ErrorKind::WouldBlock => {\n            tokio::time::sleep(Duration::from_millis(50)).await;\n        },\n        Err(e) => return Err(e),\n    }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match probe(&pipe) {\n    Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => {\n        // busy or denied: back off and retry, or use open_with_retry\n    },\n    other => other?,\n}","preventionTips":["Raise the server's named-pipe instance count to match expected concurrency","Prefer the built-in open_with_retry path, which waits out ERROR_PIPE_BUSY","Watch for long-lived connections exhausting instances; pool or recycle client connections"],"tags":["windows","named-pipes","ipc","io","backpressure"],"backgroundTag":"connection-refused","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}