Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(email): keep transient DNS failures retryable
Afloatd11054613600
diff --git a/server/email/client.ts b/server/email/client.tsindex 0dba7adb58..051f7c63c8 100644--- a/server/email/client.ts+++ b/server/email/client.ts@@ -163,7 +163,9 @@ export function sendingError(error: unknown, server: EmailServer): SendingErrorconst code = `${known.code ?? ""} ${known.originalCode ?? ""}`;const message = known.message ?? "";const answered = typeof known.responseCode === "number" ? known.responseCode : undefined;- if (/ENOTFOUND|EAI_AGAIN|EDNS|ENODATA/u.test(code)) return new SendingError("missing", server);+ if (known.code === "EAI_AGAIN" || known.originalCode === "EAI_AGAIN" ||+ (known.code === "EDNS" && /^(?:ETIMEOUT|ETIMEDOUT|ESERVFAIL|ECONNREFUSED|EREFUSED)$/u.test(known.originalCode ?? ""))) return new SendingError("no-answer", server);+ if (/ENOTFOUND|EDNS|ENODATA/u.test(code)) return new SendingError("missing", server);if (/CERT|ALTNAME|SELF_SIGNED|UNABLE_TO_VERIFY|UNABLE_TO_GET_ISSUER|DEPTH_ZERO/u.test(code) || /certificate|altnames/iu.test(message)) return new SendingError("certificate", server);// Nodemailer's words for the two mix-ups: STARTTLS on a port that starts in TLS waits for a greeting that never comes,// and TLS on a port that starts in the clear reads its plain greeting as a broken TLS record.diff --git a/server/email/host.test.ts b/server/email/host.test.tsindex 37a3ce9114..35947f8b5b 100644--- a/server/email/host.test.ts+++ b/server/email/host.test.ts@@ -6,7 +6,7 @@ import { afterEach, describe, expect, it } from "vitest";import "../server-line-packs.ts";import { setConversationLanguage } from "../server-lines.ts";import { boxUploadsDir } from "../bot-box/plan.ts";-import { EmailError, openGuard, SendingError } from "./client.ts";+import { EmailError, openGuard, sendingError, SendingError } from "./client.ts";import { outsideRouteRefused } from "../host/outside-fence.ts";import { createEmailHost, EMAIL_INTERNAL_MCP_PATH, emailAccess, emailAllowedFor, type EmailBot, type EmailHostDeps } from "./host.ts";import { createEmailService } from "./service.ts";@@ -105,6 +105,24 @@ describe("a turn's Email tools", () => {expect(host.prompt({ id: "b1", name: "Ada" })).toContain("Sending from [email protected] doesn't work until the person fixes its outgoing server");});+ it.each(["EAI_AGAIN", "ETIMEOUT", "ETIMEDOUT", "ESERVFAIL", "ECONNREFUSED", "EREFUSED"])("a temporary DNS failure (%s) does not disable later sends", async (originalCode) => {+ let calls = 0;+ const { call, service, host, rows } = await fixture({ sendMessage: async (account) => {+ calls++;+ if (calls === 1) throw sendingError(Object.assign(new Error("private resolver detail"), { code: "EDNS", originalCode }), account.smtp!);+ return { messageId: "<1@x>", accepted: ["[email protected]"], rejected: [], filed: false };+ } });+ const send = () => call("EMAIL_SEND_MESSAGE", { to: ["[email protected]"], subject: "Hi", text: "Body" });+ const failed = await send();+ expect(failed.isError).toBe(true);+ expect(failed.content[0]!.text).not.toContain("private resolver detail");+ expect(service.sendingProblem("[email protected]")).toBeUndefined();+ expect(host.prompt({ id: "b1", name: "Ada" })).not.toContain("doesn't work until the person fixes");+ expect((await send()).isError).toBeUndefined();+ expect(calls).toBe(2);+ expect(rows).toHaveLength(1);+ });+it("a header can't be smuggled into a send", async () => {let sent = 0;const { call } = await fixture({ sendMessage: (async () => { sent++; return { messageId: "<1@x>", accepted: [], rejected: [], filed: false }; }) as never });diff --git a/server/email/service.test.ts b/server/email/service.test.tsindex e99f322301..74f274b914 100644--- a/server/email/service.test.ts+++ b/server/email/service.test.ts@@ -199,6 +199,16 @@ describe("connecting a mailbox", () => {expect(sendingError(Object.assign(new Error("getaddrinfo ENOTFOUND"), { code: "EDNS" }), server).message).toBe("There is no mail server called smtp.shop.example.");});+ it("temporary DNS errors stay retryable while a nonexistent name still needs correction", () => {+ const server = { host: "smtp.shop.example", port: 587, secure: false };+ for (const error of [{ code: "EAI_AGAIN" }, { code: "EDNS", originalCode: "EAI_AGAIN" }]) {+ expect(sendingError(error, server)).toMatchObject({ fault: "no-answer", message: "smtp.shop.example didn't answer on port 587." });+ }+ for (const error of [{ code: "ENOTFOUND" }, { code: "EDNS", originalCode: "ENOTFOUND" }, { code: "EDNS", originalCode: "ENODATA" }]) {+ expect(sendingError(error, server)).toMatchObject({ fault: "missing", message: "There is no mail server called smtp.shop.example." });+ }+ });+it("a mailbox saved read-only, which said so as its problem, is not held back by it", async () => {const { email, dataDir } = service(() => ({ messages: 1 }), () => SILENT());await email.connect({ address: "[email protected]", password: PASSWORD });