{"record":{"id":"44cead294505a75f","repo":"stalwartlabs/stalwart","slug":"server-threaderror","errorCode":null,"errorMessage":"Server::ThreadError","messagePattern":"Server::ThreadError","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/services/src/task_manager/imip.rs","lineNumber":301,"sourceCode":"                        QueueId = queue_id,\n                    );\n                } else {\n                    trc::event!(\n                        Calendar(trc::CalendarEvent::ItipMessageError),\n                        From = from,\n                        To = to,\n                        AccountId = account_id,\n                        DocumentId = document_id,\n                        Reason = format!(\n                            \"Server rejected DATA: {}\",\n                            std::str::from_utf8(&response).unwrap().trim()\n                        ),\n                    );\n                }\n            })\n            .await\n            .map_err(|_| {\n                trc::Error::new(trc::EventType::Server(trc::ServerEvent::ThreadError))\n                    .caused_by(trc::location!())\n            })?;\n        }\n    }\n\n    Ok(TaskResult::Success(vec![]))\n}\n\npub struct Details {\n    pub subject: String,\n    pub body: String,\n}\n\n#[allow(clippy::too_many_arguments)]\npub async fn build_itip_template(\n    server: &Server,\n    account_info: &AccountInfo,\n    account_id: u32,","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/stalwartlabs/stalwart/blob/e96200385781a6a9995a8b839ac27d6c75a983ee/crates/services/src/task_manager/imip.rs#L283-L319","documentation":"An internal trc::Error with EventType::Server(ServerEvent::ThreadError) raised in `send_imip` (crates/services/src/task_manager/imip.rs) when the spawned async task/job fails — the `.await` on the task join returns Err and is mapped to this event. It signals the iMIP (email-based scheduling) send worker could not complete, not a message-level failure.","triggerScenarios":"`send_imip` spawns a task (e.g. via a task queue/join handle) to deliver iMIP messages; the awaited result errors (task panicked, was cancelled, or the worker failed), and `map_err` converts it into Server::ThreadError with `trc::location!()` context.","commonSituations":"Mail delivery worker crashes under load; runtime shutdown/cancellation kills the spawned task mid-send; a panic inside the per-message delivery closure; thread pool exhaustion.","solutions":["Look up the server logs for the ThreadError entry and the `caused_by` location to find the underlying task failure.","Re-run/queue the affected iMIP messages — the scheduling messages were not confirmed delivered.","Fix the panic or resource issue inside the spawned delivery task (e.g. mail server connectivity, worker pool sizing)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// at the task_manager call site\nmatch send_imip(&mut core, &account_id, &messages).await {\n    Err(err) if err.is_server_thread_error() => {\n        tracing::error!(?err, \"iMIP send task failed; requeueing messages\");\n        requeue(messages);\n    }\n    other => other?,\n}","preventionTips":["Ensure spawned delivery tasks are panic-free: wrap per-message logic and log instead of unwrapping.","Handle graceful shutdown/cancellation so tasks aren't killed mid-send.","Persist iMIP messages before dispatch so failures can be requeued.","Monitor worker-pool health and mail-server connectivity."],"tags":["imip","task-manager","worker-thread","email"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e96200385781a6a9995a8b839ac27d6c75a983ee","analyzedAt":"2026-09-06T22:07:17.982Z","contentChangedAt":"2026-09-06T22:07:17.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}