Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix: IMAP poller retries on auth failure instead of permanently stopping
Gener8318e0ea3fbd
diff --git a/src/email-worker/src/imap-poller-do.test.ts b/src/email-worker/src/imap-poller-do.test.tsindex 4357421bd..3b6323449 100644--- a/src/email-worker/src/imap-poller-do.test.ts+++ b/src/email-worker/src/imap-poller-do.test.ts@@ -304,7 +304,7 @@ describe("alarm — connection failure & backoff", () => {// ─── Auth failure ───describe("alarm — auth failure", () => {- it("stops polling on authentication error from connect", async () => {+ it("retries with backoff on authentication error instead of stopping", async () => {const { durable, ctx } = createDO()mockConnect.mockRejectedValueOnce(new MockImapAuthError("IMAP A1 failed: A1 NO [AUTHENTICATIONFAILED]"))@@ -315,7 +315,8 @@ describe("alarm — auth failure", () => {expect.anything(), "aea_test1", "ws_test1",expect.objectContaining({ status: "error", errorMessage: expect.stringContaining("AUTHENTICATIONFAILED") }))- expect(ctx.storage.deleteAlarm).toHaveBeenCalled()+ expect(ctx.storage.setAlarm).toHaveBeenCalled()+ expect(ctx.storage.deleteAlarm).not.toHaveBeenCalled()})})diff --git a/src/email-worker/src/imap-poller-do.ts b/src/email-worker/src/imap-poller-do.tsindex 7381059dc..bdfb30b84 100644--- a/src/email-worker/src/imap-poller-do.ts+++ b/src/email-worker/src/imap-poller-do.ts@@ -214,9 +214,7 @@ export class ImapPollerDO extends DurableObject<EmailEnv> {})if (err instanceof ImapAuthError) {- pollLog.warn("auth error — stopping polling, user must fix credentials")- await this.ctx.storage.deleteAlarm()- return+ pollLog.warn("auth error — will retry with backoff", { permanent: err.permanent })}const currentBackoff = (await this.ctx.storage.get<number>("backoffMs")) ?? 0diff --git a/src/email-worker/src/lib/imap-client.ts b/src/email-worker/src/lib/imap-client.tsindex 6e2d1cd82..c17c3000e 100644--- a/src/email-worker/src/lib/imap-client.ts+++ b/src/email-worker/src/lib/imap-client.ts@@ -16,9 +16,11 @@ export class ImapError extends Error {}export class ImapAuthError extends ImapError {- constructor(message: string) {+ readonly permanent: boolean+ constructor(message: string, permanent = false) {super(message)this.name = "ImapAuthError"+ this.permanent = permanent}}@@ -61,7 +63,11 @@ export class ImapClient {try {await this.sendCommand(tag, `LOGIN ${user} ${pass}`)} catch (err) {- if (err instanceof ImapError) throw new ImapAuthError(err.message)+ if (err instanceof ImapError) {+ const upper = err.message.toUpperCase()+ const permanent = upper.includes("[AUTHENTICATIONFAILED]") || upper.includes("INVALID CREDENTIALS")+ throw new ImapAuthError(err.message, permanent)+ }throw err}}