{"record":{"id":"f892d416553fa786","repo":"nautechsystems/nautilus_trader","slug":"failed-to-start-spot-public-json-ws-handler-task","errorCode":null,"errorMessage":"Failed to start Spot public JSON WS handler task: {e}","messagePattern":"Failed to start Spot public JSON WS handler task: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/websocket/public_json/client.rs","lineNumber":664,"sourceCode":"                }\n            }\n        }) {\n            cancellation_token.cancel();\n            bytes_task.abort();\n            let mut shutdown_errors = Vec::new();\n\n            if let Some(error) =\n                finish_slot_task(&mut handler_task, \"Binance Spot public JSON handler\").await\n            {\n                shutdown_errors.push(error);\n            }\n\n            if let Some(error) =\n                finish_slot_task(&mut bytes_task, \"Binance Spot public JSON bytes\").await\n            {\n                shutdown_errors.push(error);\n            }\n            anyhow::bail!(if shutdown_errors.is_empty() {\n                format!(\"Failed to start Spot public JSON WS handler task: {e}\")\n            } else {\n                format!(\n                    \"Failed to start Spot public JSON WS handler task: {e}; startup rollback failed: \\\n                     {}\",\n                    shutdown_errors.join(\"; \")\n                )\n            });\n        }\n\n        if let Some(control) = &socket_control {\n            control.register(move || reconnect_handle.request_reconnect());\n        }\n\n        Ok(ConnectionSlot {\n            cmd_tx,\n            streams: Vec::new(),\n            handler_task,","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/websocket/public_json/client.rs#L646-L682","documentation":"The final startup step of create_connection — spawning the handler task for the slot — failed with error `e`. Before bailing, the code rolls back the already-started bytes task (collecting shutdown_errors) and includes any rollback failures in the message. The slot connection is not usable.","triggerScenarios":"create_connection (via connect or subscribe) when the handler task fails to spawn or dies immediately — runtime spawn failure, runtime shutdown in progress, or handler setup erroring on its first poll.","commonSituations":"Creating WS connections during process/runtime teardown; tokio task limits hit; a handler that depends on a channel that was already closed by an earlier failure.","solutions":["Retry connect/subscribe; a transient spawn/start failure usually clears on the next attempt.","If the message contains 'startup rollback failed' segments, inspect them for leaked bytes-task errors indicating deeper runtime problems.","Ensure connection creation happens on a live, non-shutting-down tokio runtime.","Check system resources (task/thread limits) if spawn failures persist."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in 0..3 {\n    match client.connect().await {\n        Ok(()) => break,\n        Err(e) if e.to_string().contains(\"handler task\") && attempt < 2 => tokio::time::sleep(backoff(attempt)).await,\n        Err(e) => return Err(e),\n    }\n}","preventionTips":["Avoid establishing connections during process/runtime shutdown.","Monitor tokio task counts to avoid spawn failures from resource exhaustion.","Retry connection startup with bounded backoff; spawn failures are often transient.","Inspect rollback-error suffixes for root causes in earlier startup steps."],"tags":["websocket","binance","spot","task-spawn","startup"],"backgroundTag":"network-request-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}