spacedriveapp/spacedrive · warning
Connection closed without response
Error message
Connection closed without response
What it means
Returned by FileSyncService::sync_now when the in-memory active_syncs map (Arc<RwLock<HashMap>>) already contains conduit_id, meaning another sync for the same conduit is currently running. This is a client-side concurrency guard, not a DB constraint — the map is populated when a sync starts and cleaned up when it finishes.
Source
Thrown at packages/ts-client/src/transport.ts:362
const requestLine = JSON.stringify(request) + "\n";
await socket.write(requestLine);
// Read response
const reader = socket.reader;
let buffer = "";
for await (const chunk of reader) {
buffer += new TextDecoder().decode(chunk);
const newlineIndex = buffer.indexOf("\n");
if (newlineIndex !== -1) {
const line = buffer.slice(0, newlineIndex).trim();
socket.end();
return JSON.parse(line);
}
}
throw new Error("Connection closed without response");
}
async subscribe(
callback: (event: any) => void,
options?: SubscriptionOptions,
): Promise<() => void> {
// @ts-ignore - Bun global
const socket = await Bun.connect({
unix: this.socketPath,
});
// Subscribe to relevant events (excludes spammy LogMessage/JobProgress)
const subscribeRequest = {
Subscribe: {
event_types: options?.event_types ?? DEFAULT_EVENT_SUBSCRIPTION,
filter: options?.filter ?? null,
},
};View on GitHub (pinned to 6dfeccf211)
Solutions
- Wait for the in-flight sync to finish (poll its SyncHandle / job status) instead of issuing a second sync_now.
- Debounce the trigger in the client so concurrent calls coalesce into one.
- If the map is stuck due to a panicked sync task, restart the daemon to clear active_syncs.
Example fix
// before
let handle = sync_svc.sync_now(conduit_id).await?; // second call errors
// after
let handle = match sync_svc.sync_now(conduit_id).await {
Ok(h) => h,
Err(e) if e.to_string().contains("already in progress") => {
return Ok(()); // a sync is already running; nothing to do
}
Err(e) => return Err(e),
}; Defensive patterns
Strategy: retry
Try / catch
// Coalesce duplicate triggers: in-progress is not a failure.
match svc.sync_now(id).await {
Ok(h) => Ok(Some(h)),
Err(e) if e.to_string().contains("already in progress") => Ok(None),
Err(e) => Err(e),
} Prevention
- Debounce 'Sync now' buttons and coalesce scheduler/manual triggers per conduit.
- Track the returned SyncHandle and wait for completion before allowing a new trigger.
- If active_syncs never drains (stuck task), restart the daemon to clear the map.
When it happens
Trigger: Invoking sync_now for the same conduit twice before the first run completes: double-trigger from UI, a scheduler tick colliding with a manual sync, or a retry fired while the original request is still executing.
Common situations: Impatient double-click on 'Sync now'; overlapping cron/schedule and manual trigger; long-running first sync (large tree) during which a second request arrives.
Understand the failure class
- Connection failures: ECONNREFUSED, ECONNRESET, and friends — why connections get refused, reset, or dropped.
Related errors
- Library with ID '${libraryId}' not found
- This operation requires an active library. Use switchToLibra
- ${isQuery ? "Query" : "Action"} failed: ${JSON.stringify(err
- Unexpected response: ${JSON.stringify(response)}
- No library selected. Use client.switchToLibrary() first.
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/a5992a4dc2326ceb.
Report an issue: GitHub.