{"record":{"id":"11bd4a8d82daed22","repo":"tursodatabase/turso","slug":"local-sync-server-failed-to-start-after-spawn-att","errorCode":null,"errorMessage":"local sync server failed to start after {SPAWN_ATTEMPTS} attempts","messagePattern":"local sync server failed to start after (.+?) attempts","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"bindings/rust/src/sync.rs","lineNumber":1271,"sourceCode":"                                     before becoming ready (attempt {attempt}/{SPAWN_ATTEMPTS})\"\n                                );\n                                break;\n                            }\n                            None => {\n                                if started.elapsed() > READY_TIMEOUT {\n                                    let _ = child.kill();\n                                    let _ = child.wait();\n                                    return Err(anyhow!(\n                                        \"local sync server on port {port} did not become ready \\\n                                         within {READY_TIMEOUT:?}\"\n                                    ));\n                                }\n                            }\n                        }\n                        sleep(Duration::from_millis(100));\n                    }\n                }\n                Err(anyhow!(\n                    \"local sync server failed to start after {SPAWN_ATTEMPTS} attempts\"\n                ))\n            }\n        }\n\n        pub fn db_url(&self) -> &str {\n            &self.db_url\n        }\n\n        pub async fn db_sql(&self, sql: &str) -> Result<Vec<Vec<Value>>> {\n            let resp = self\n                .client\n                .post(format!(\"{}{}/v2/pipeline\", self.user_url, self.db_prefix))\n                .header(\"Host\", &self.host)\n                .json(&json!({\n                    \"requests\": [{\n                        \"type\": \"execute\",\n                        \"stmt\": { \"sql\": sql }","sourceCodeStart":1253,"sourceCodeEnd":1289,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/bindings/rust/src/sync.rs#L1253-L1289","documentation":"Returned when TursoServer::spawn exhausts SPAWN_ATTEMPTS (10) attempts without the sync server becoming ready. Each attempt that exits early (typically because the port was reserved or taken) is retried on another port; this error means every attempt either exited or timed out (bindings/rust/src/sync.rs:1174). The per-attempt stderr above the error says which.","triggerScenarios":"The spawned binary cannot start at all - wrong binary on PATH, tursodb built without the sync serve subcommand, or all candidate ports occupied; also reached when each attempt burns the full 60s readiness timeout on a starved machine.","commonSituations":"Leftover tursodb server processes from a killed test run holding ports; PATH resolving to an old binary after a rebase; CI environments with a narrow usable port range; a previous failed run leaving orphans behind.","solutions":["Kill leftover servers (pkill -f tursodb, or tman kill) and rerun the test","Verify the binary the harness spawns: run tursodb sync serve --help manually and confirm it exists","Check the 'exited with {status}' lines the harness prints per attempt - they carry the real exit cause","Free ports or widen the ephemeral port range available to the test user"],"exampleFix":"# before: tests fail with 'local sync server failed to start after 10 attempts'\npgkill() { pkill -f 'tursodb.*sync'; }\npgkill && sleep 1 && cargo test -p turso sync_tests","handlingStrategy":"retry","validationCode":"let out = std::process::Command::new(\"tursodb\")\n    .args([\"sync\", \"serve\", \"--help\"])\n    .output()?;\nanyhow::ensure!(out.status.success(), \"tursodb binary lacks sync serve\");","typeGuard":null,"tryCatchPattern":"match TursoServer::spawn(&ctx).await {\n    Ok(server) => Ok(server),\n    Err(e) if e.to_string().contains(\"SPAWN_ATTEMPTS\").or(e.to_string().contains(\"failed to start\")) => {\n        let _ = std::process::Command::new(\"pkill\").arg(\"-f\").arg(\"tursodb\").status();\n        TursoServer::spawn(&ctx).await\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Kill leftover tursodb sync servers between test runs","Pre-flight check that the server binary exists and supports sync serve","Ensure the test user has a wide enough range of free ephemeral ports"],"tags":["sync","test-harness","port-conflict","process-spawn","rust"],"backgroundTag":"process-spawn-failed","analyzedSha":"492c4a71cd7c2649e7df83da1471b74f4b1c7aa9","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}