{"record":{"id":"ad6b3d8ca3176995","repo":"nautechsystems/nautilus_trader","slug":"failed-to-terminate-derive-data-tasks-e","errorCode":null,"errorMessage":"Failed to terminate Derive data tasks: {e}","messagePattern":"Failed to terminate Derive data tasks: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/adapters/derive/src/data.rs","lineNumber":2231,"sourceCode":"    replay\n}\n\nimpl DeriveDataClient {\n    async fn join_session_tasks(&self) -> anyhow::Result<()> {\n        self.session_tasks.begin_shutdown();\n        self.session_tasks\n            .finish_shutdown(Duration::from_secs(1), Duration::from_secs(2))\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to terminate Derive data session tasks: {e}\"))?;\n        Ok(())\n    }\n\n    async fn join_pending_tasks(&self) -> anyhow::Result<()> {\n        self.pending_tasks.begin_shutdown();\n        self.pending_tasks\n            .finish_shutdown(Duration::from_secs(1), Duration::from_secs(2))\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to terminate Derive data tasks: {e}\"))?;\n        Ok(())\n    }\n}\n\nfn cache_instrument(\n    instruments: &Arc<AtomicMap<InstrumentId, InstrumentAny>>,\n    instrument: &InstrumentAny,\n) {\n    instruments.insert(instrument.id(), instrument.clone());\n}\n\nfn process_ticker_quote(\n    msg: &DeriveTickerMsg,\n    price_precision: u8,\n    size_precision: u8,\n    ts_init: UnixNanos,\n    quote_cache: &mut QuoteCache,\n) -> anyhow::Result<Option<QuoteTick>> {","sourceCodeStart":2213,"sourceCodeEnd":2249,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/derive/src/data.rs#L2213-L2249","documentation":"Analogous to join_session_tasks, `join_pending_tasks` shuts down the Derive data client's pending (in-flight request) task group with 1s/2s grace periods. If the pending tasks do not finish within the deadlines, `finish_shutdown` errors and this message wraps it. It means outstanding data request tasks could not be cleanly awaited during disconnect.","triggerScenarios":"Calling client disconnect/shutdown while request tasks (HTTP/ws request futures) are still pending and exceed the 1s/2s shutdown timeouts.","commonSituations":"Shutting down with many slow in-flight Derive REST requests; a hung HTTP call without a short timeout blocking the pending task group; abrupt teardown under load.","solutions":["Retry shutdown once the network or in-flight requests settle.","Give in-flight requests shorter individual timeouts so pending tasks end promptly at shutdown.","Inspect the inner error to identify which pending task stalled.","Accept and log if this happens only at process exit and results are no longer needed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match client.join_pending_tasks().await {\n    Ok(()) => {}\n    Err(e) => tracing::warn!(\"pending tasks did not shut down cleanly: {e:#}\"),\n}","preventionTips":["Use short per-request timeouts so pending tasks end quickly","Avoid shutting down with many in-flight requests","Drain requests before disconnect where possible","Log the inner error to identify the stalled request"],"tags":["derive","shutdown","timeout","async"],"backgroundTag":"request-timeout","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"}