{"record":{"id":"23fba053feb019f7","repo":"linera-io/linera-protocol","slug":"failed-to-start-node-service","errorCode":null,"errorMessage":"Failed to start node service","messagePattern":"Failed to start node service","errorType":"exception","errorClass":"anyhow","httpStatus":null,"severity":"error","filePath":"linera-service/src/cli_wrappers/wallet.rs","lineNumber":572,"sourceCode":"        }\n        for (name, secs) in subscription_ttls {\n            command.args([\"--subscription-ttl-secs\", &format!(\"{name}={secs}\")]);\n        }\n        let child = command\n            .args([\"--port\".to_string(), port.to_string()])\n            .spawn_into()?;\n        let client = reqwest_client();\n        for i in 0..10 {\n            linera_base::time::timer::sleep(Duration::from_secs(i)).await;\n            let request = client.get(format!(\"http://localhost:{port}/\")).send().await;\n            if request.is_ok() {\n                tracing::info!(\"Node service has started\");\n                return Ok(NodeService::new(port, child));\n            } else {\n                tracing::warn!(\"Waiting for node service to start\");\n            }\n        }\n        bail!(\"Failed to start node service\");\n    }\n\n    /// Runs `linera service` with a controller application.\n    pub async fn run_node_service_with_controller(\n        &self,\n        port: impl Into<Option<u16>>,\n        process_inbox: ProcessInbox,\n        controller_id: &ApplicationId,\n        operators: &[(String, PathBuf)],\n    ) -> Result<NodeService> {\n        let port = port.into().unwrap_or(8080);\n        let mut command = self.command().await?;\n        command.arg(\"service\");\n        if let ProcessInbox::Skip = process_inbox {\n            command.arg(\"--listener-skip-process-inbox\");\n        }\n        if let Ok(var) = env::var(CLIENT_SERVICE_ENV) {\n            command.args(var.split_whitespace());","sourceCodeStart":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-service/src/cli_wrappers/wallet.rs#L554-L590","documentation":"`run_node_service_with_all_options` spawns `linera service --port <port>` (default 8080, plus any CLIENT_SERVICE_ENV args) and then polls `GET http://localhost:{port}/` up to 10 times with sleeps of 0..9 seconds (~45s budget). Any successful HTTP response counts as started, so the bail means the child never answered at all: it died, cannot bind the port, or started too slowly. Used by e2e tests like `test_wasm_end_to_end_counter_subscription`.","triggerScenarios":"The `linera service` child fails to bind its port (already in use), crashes on startup (bad wallet/config, storage error, invalid extra args from CLIENT_SERVICE_ENV), or takes longer than the ~45s polling budget on a loaded machine.","commonSituations":"Default port 8080 occupied by another dev service or proxy; a previous NodeService leaked and still holds the port; an invalid wallet/keystore making the child exit immediately; CI runners under heavy load exceeding the fixed retry budget.","solutions":["Check whether the port is free (`lsof -i :8080`); free it or pass a different port to the wrapper","Run `linera service --port <port>` manually with the same wallet/config to see the child's startup error","Watch for the 'Waiting for node service to start' warns and inspect the child process output/stderr","After cleanup, retry the wrapper call; on slow runners choose an explicit free port instead of the 8080 default"],"exampleFix":"// before\nlet service = client.run_node_service_with_all_options(None, ...).await?; // port defaults to 8080\n\n// after\nlet service = client.run_node_service_with_all_options(Some(18080), ...).await?; // explicit free port","handlingStrategy":"retry","validationCode":"// Pick a free port up front instead of relying on the 8080 default.\nlet port = linera_base::port::get_free_endpoint().await?\n    .port()\n    .expect(\"endpoint has a port\");\nlet service = client.run_node_service_with_all_options(Some(port), ...).await?;","typeGuard":null,"tryCatchPattern":"match client.run_node_service_with_all_options(Some(port), ...).await {\n    Err(e) if e.to_string() == \"Failed to start node service\" => {\n        // poll already ran ~45s; failure is structural (dead child / port conflict)\n        free_port_or_pick_another(port).await?;\n        client.run_node_service_with_all_options(Some(new_port), ...).await?\n    }\n    result => result,\n}","preventionTips":["Pass an explicit free port to every spawned service (node service, faucet) — never stack on 8080 defaults","Drop NodeService handles deterministically in tests so children die and ports are released","When it fails, run `linera service` manually with the same wallet and env (CLIENT_SERVICE_ENV is injected!) to see the child's error"],"tags":["node-service","startup","port","cli-wrappers","integration-tests"],"backgroundTag":"service-startup-timeout","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}