{"record":{"id":"750d3b845a859f20","repo":"nanocoai/nanoclaw","slug":"message-delivery-failed-will-retry","errorCode":null,"errorMessage":"Message delivery failed, will retry","messagePattern":"Message delivery failed, will retry","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/delivery.ts","lineNumber":271,"sourceCode":"      if (attempts >= MAX_DELIVERY_ATTEMPTS) {\n        log.error('Message delivery failed permanently, giving up', {\n          messageId: msg.id,\n          sessionId: session.id,\n          attempts,\n          err,\n        });\n        try {\n          await withExistingMailboxSession(agentGroup.id, session.id, (mailbox) => mailbox.markDeliveryFailed(msg.id));\n          deliveryAttempts.delete(msg.id);\n        } catch (markErr) {\n          log.error('Failed to record permanent delivery failure', {\n            messageId: msg.id,\n            sessionId: session.id,\n            err: markErr,\n          });\n        }\n      } else {\n        log.warn('Message delivery failed, will retry', {\n          messageId: msg.id,\n          sessionId: session.id,\n          attempt: attempts,\n          maxAttempts: MAX_DELIVERY_ATTEMPTS,\n          err,\n        });\n      }\n    }\n  }\n}\n\nasync function deliverMessage(\n  msg: {\n    id: string;\n    kind: string;\n    platformId: string | null;\n    channelType: string | null;\n    threadId: string | null;","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/delivery.ts#L253-L289","documentation":"Delivering an outbound message via the channel adapter failed (non-marking error path); the message stays pending and will be retried up to MAX_DELIVERY_ATTEMPTS. Includes the attempt counter and underlying error for diagnosis.","triggerScenarios":"`drainSession` → adapter send throws (network error, channel API 5xx/rate limit, expired token) for a message in outbound.db; message not yet marked delivered.","commonSituations":"Channel outage or rate limiting; revoked bot token; transient DNS/network failure on the host.","solutions":["Inspect `err` in the same log line and `logs/nanoclaw.error.log` for the adapter failure","Fix the credential (re-auth the channel) or wait out a rate limit/outage; retries resume automatically","If attempts exhaust, check the channel adapter's health and re-send from the session"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await adapter.send(msg); } catch (err) { /* backoff; inspect err; only mark delivered on success */ }","preventionTips":["Keep channel credentials fresh; monitor logs/nanoclaw.error.log","Back off on rate-limit errors instead of tight retries","Alert when attempts approach MAX_DELIVERY_ATTEMPTS"],"tags":["delivery","retry","channel-adapter","network"],"backgroundTag":"message-delivery-retry","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}