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

  1. Wait for the in-flight sync to finish (poll its SyncHandle / job status) instead of issuing a second sync_now.
  2. Debounce the trigger in the client so concurrent calls coalesce into one.
  3. 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

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

Related errors


AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16). Data as JSON: /api/errors/a5992a4dc2326ceb. Report an issue: GitHub.