{"record":{"id":"bbf3feeca3928cdb","repo":"nautechsystems/nautilus_trader","slug":"failed-to-start-market-shard-forwarder-e","errorCode":null,"errorMessage":"Failed to start market shard forwarder: {e}","messagePattern":"Failed to start market shard forwarder: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/websocket/pool.rs","lineNumber":677,"sourceCode":"            .ok_or_else(|| anyhow::anyhow!(\"Market shard receiver unavailable after connect\"))?;\n        let forwarder = match self.spawn_forwarder(rx, is_primary) {\n            Ok(forwarder) => forwarder,\n            Err((e, forwarder)) => {\n                let shard = Box::new(ShardEntry {\n                    client,\n                    handle,\n                    forwarder,\n                    owned: 0,\n                    closing: true,\n                });\n\n                if let Err(close_error) = self.close_shard(id, shard).await {\n                    anyhow::bail!(\n                        \"Failed to start market shard forwarder: {e}; startup rollback failed: \\\n                         {close_error}\"\n                    );\n                }\n                anyhow::bail!(\"Failed to start market shard forwarder: {e}\");\n            }\n        };\n\n        let shard = ShardEntry {\n            client,\n            handle,\n            forwarder,\n            owned: 0,\n            closing: false,\n        };\n        let rejected_shard = {\n            let mut state = self.state.lock();\n\n            if self.closed.load(Ordering::Acquire) {\n                Some(shard)\n            } else {\n                state.shards.insert(id, shard);\n                None","sourceCodeStart":659,"sourceCodeEnd":695,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/websocket/pool.rs#L659-L695","documentation":"Polymarket market shard startup failed: after spawning a new shard connection, if the forwarder task immediately returns an error (e), connect_new_shard rolls back by closing the shard. If the rollback close also fails, both errors are combined into one bail message; otherwise only the original forwarder error is reported.","triggerScenarios":"Calling assign() on the market connection pool when the pool is open and a new shard must be created, but the spawned forwarder task exits with an error during startup (e.g. websocket connect or subscription failure), and possibly the rollback close_shard also errors.","commonSituations":"Polymarket websocket endpoint unreachable or dropping connections during shard spin-up; network instability at startup; auth/subscription rejected immediately causing the forwarder to fail before it runs.","solutions":["Check network connectivity and the Polymarket websocket URL configuration","Inspect the inner error ({e}) in the message — it names the actual forwarder failure; fix that root cause first","If 'startup rollback failed' also appears, investigate why close_shard failed (shutdown_errors accumulated in pool state)","Retry pool assignment; transient connect failures may succeed on a later attempt"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before assigning, confirm pool is open and endpoint reachable\n// (Rust-style sketch)\nif pool.is_closed() { return Err(anyhow::anyhow!(\"pool closed\")); }\n// Optionally probe the websocket URL with a quick TCP/TLS connect first","typeGuard":null,"tryCatchPattern":"match pool.assign(...).await {\n    Ok(id) => /* use shard id */,\n    Err(e) if e.to_string().contains(\"Failed to start market shard forwarder\") => {\n        log::warn!(\"shard startup failed: {e:#}; retrying after backoff\");\n        // backoff then retry\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Check pool lifecycle before assigning subscriptions","Monitor the inner forwarder error text to address the true root cause","Apply connection retry/backoff at the application level","Keep Polymarket endpoint configuration current"],"tags":["websocket","polymarket","sharding","startup"],"backgroundTag":"websocket-connect-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}