{"record":{"id":"268aaac4c7bb141f","repo":"astrid-runtime/astrid","slug":"fskit-service-control-endpoint-is-already-present","errorCode":null,"errorMessage":"FSKit service control endpoint is already present","messagePattern":"FSKit service control endpoint is already present","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-fskit/src/service.rs","lineNumber":203,"sourceCode":"            .components()\n            .any(|component| matches!(component, std::path::Component::ParentDir))\n    {\n        bail!(\"FSKit service control path is malformed\");\n    }\n    let parent = control_path\n        .parent()\n        .context(\"FSKit service control path has no parent\")?;\n    platform_fs::validate_private_directory(parent)\n        .context(\"validate private FSKit control parent\")?;\n    platform_fs::verify_no_redirects(control_path)\n        .context(\"reject redirected FSKit control path\")?;\n    if control_path != resource_path.join(\"process-control.sock\") {\n        bail!(\"FSKit service control path is not the kernel endpoint\");\n    }\n    if local_transport::endpoint_is_present(control_path)\n        .context(\"inspect FSKit service control endpoint\")?\n    {\n        bail!(\"FSKit service control endpoint is already present\");\n    }\n    Ok(())\n}\n\nfn bind_control(path: &Path) -> Result<LocalListener> {\n    local_transport::bind(path)\n        .with_context(|| format!(\"bind FSKit service control {}\", path.display()))\n}\n\nasync fn probe_callback(launch: &StorageProviderServiceLaunchV1) -> Result<()> {\n    let mut stream = local_transport::connect(&launch.lease.callback_path)\n        .await\n        .context(\"connect FSKit lease callback\")?;\n    let request = StorageFilesystemRequestV2 {\n        protocol_version: STORAGE_FILESYSTEM_PROTOCOL_V2,\n        request_id: format!(\"fskit-service-{}\", launch.lease.mount_id),\n        lease_token: launch.lease.lease_token.clone(),\n        operation: StorageFilesystemOperationV2::Stat {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-fskit/src/service.rs#L185-L221","documentation":"Before binding, validate_control_path checks local_transport::endpoint_is_present on the control path; if a listener/socket already exists there, another service instance is running (or a stale socket remains) and launch is aborted to avoid double-binding.","triggerScenarios":"validate_launch called while a previous FSKit service instance still holds the endpoint at resource_path/process-control.sock, or a crashed run left the socket file behind without cleanup.","commonSituations":"Starting a second instance of the same service; a previous run crashed without unlinking the socket; container restart reusing a volume with the old socket file.","solutions":["Stop the existing service instance holding the endpoint, then relaunch","Remove the stale socket file if no process is listening","Ensure shutdown paths unbind/unlink the control socket before exit"],"exampleFix":"// before\nservice.launch(&lease)?; // endpoint still bound by old instance\n// after\nif local_transport::endpoint_is_present(&control_path)? { service.shutdown()?; }\nservice.launch(&lease)?;","handlingStrategy":"try-catch","validationCode":"fn endpoint_free(control: &std::path::Path) -> bool {\n    !local_transport::endpoint_is_present(control).unwrap_or(true)\n}","typeGuard":null,"tryCatchPattern":"match provider.run(launch) {\n    Err(e) if e.to_string().contains(\"already present\") => {\n        cleanup_stale_socket(&launch.control_path)?;\n        provider.run(launch).await\n    }\n    r => r,\n}","preventionTips":["Ensure shutdown handlers unbind the control socket","Use a supervisor/single-instance lock so two instances never race","On startup, detect and clean sockets left by crashed runs"],"tags":["fskit","socket","address-in-use","lifecycle"],"backgroundTag":"address-already-in-use","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}