{"record":{"id":"c86ea2efda36ee59","repo":"nautechsystems/nautilus_trader","slug":"architect-ax-orders-websocket-handler-failed-err","errorCode":null,"errorMessage":"Architect AX orders WebSocket handler failed: {error}","messagePattern":"Architect AX orders WebSocket handler failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/websocket/orders/client.rs","lineNumber":751,"sourceCode":"        // Send disconnect first to allow graceful cleanup before signal\n        self.cancellation_token.load().cancel();\n        let _ = self.send_cmd(HandlerCommand::Disconnect).await;\n        tokio::time::sleep(Duration::from_millis(50)).await;\n        self.signal.store(true, Ordering::Release);\n\n        let outcome = self\n            .task_handle\n            .finish(Duration::from_secs(2), Duration::from_secs(2))\n            .await;\n        *self.reconnect_headers.lock() = None;\n\n        if let Some(control) = &self.socket_control {\n            control.deregister();\n        }\n\n        match outcome {\n            None | Some(TaskJoinOutcome::Completed(()) | TaskJoinOutcome::Aborted) => Ok(()),\n            Some(TaskJoinOutcome::Failed(error)) => Err(anyhow::anyhow!(\n                \"Architect AX orders WebSocket handler failed: {error}\"\n            )),\n            Some(TaskJoinOutcome::Incomplete) => Err(anyhow::anyhow!(\n                \"Architect AX orders WebSocket handler did not stop after abort\"\n            )),\n        }\n    }\n\n    async fn send_cmd(&self, cmd: HandlerCommand) -> AxOrdersWsResult<()> {\n        let guard = self.cmd_tx.read().await;\n        guard\n            .send(cmd)\n            .map_err(|e| AxOrdersWsClientError::ChannelError(e.to_string()))\n    }\n}\n\nimpl Drop for AxOrdersWebSocketClient {\n    fn drop(&mut self) {","sourceCodeStart":733,"sourceCodeEnd":769,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/websocket/orders/client.rs#L733-L769","documentation":"Returned by the Architect AX orders WebSocket client's close(). It mirrors the data client: when the joined orders handler task ended with TaskJoinOutcome::Failed, close() wraps that error in this message and returns it.","triggerScenarios":"Calling OrdersWebSocketClient::close() when the internal orders handler task previously exited with an error — e.g. order-submit/cancel command handling failed, the upstream socket errored, or the handler returned Err.","commonSituations":"Order gateway connection broke during a session; a submit/cancel command channel error killed the handler; teardown after a handler failure in tests or on disconnect.","solutions":["Read the wrapped inner error to identify the actual handler failure","Check connectivity/auth to the Architect AX order gateway around the failure time","Treat the Err as informational during teardown if the session is already ending (log instead of propagate)","Fix the underlying handler bug if it reproduces with specific commands"],"exampleFix":"// before\norders.close().await?;\n// after\nif let Err(e) = orders.close().await {\n    tracing::warn!(\"orders ws close: {e:#}\");\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Rust\nif let Err(e) = orders.close().await {\n    tracing::warn!(\"orders ws handler failed on close: {e:#}\");\n}","preventionTips":["Handle command-channel send/recv errors inside the orders handler rather than aborting the task on transient failures","Monitor order-gateway connectivity; reconnect instead of letting the handler die","Inspect the wrapped inner error to find the real cause","Keep teardown logging-based rather than propagating during shutdown"],"tags":["websocket","orders","async","shutdown"],"backgroundTag":"background-task-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"}