mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-26 16:06:16 +00:00
Handle transient Slack request errors without crashing the gateway (openclaw#23787) thanks @graysurf
Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: graysurf <10785178+graysurf@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -93,10 +93,22 @@ describe("installUnhandledRejectionHandler - fatal detection", () => {
|
||||
Object.assign(new Error("DNS resolve failed"), { code: "UND_ERR_DNS_RESOLVE_FAILED" }),
|
||||
Object.assign(new Error("Connection reset"), { code: "ECONNRESET" }),
|
||||
Object.assign(new Error("Timeout"), { code: "ETIMEDOUT" }),
|
||||
Object.assign(
|
||||
new Error(
|
||||
"A request error occurred: Client network socket disconnected before secure TLS connection was established",
|
||||
),
|
||||
{ code: "slack_webapi_request_error" },
|
||||
),
|
||||
Object.assign(new Error("A request error occurred: getaddrinfo EAI_AGAIN slack.com"), {
|
||||
code: "slack_webapi_request_error",
|
||||
original: { code: "EAI_AGAIN", syscall: "getaddrinfo", hostname: "slack.com" },
|
||||
}),
|
||||
Object.assign(new Error("A request error occurred: unknown"), {
|
||||
code: "slack_webapi_request_error",
|
||||
original: Object.assign(new Error("connect timeout"), {
|
||||
code: "UND_ERR_CONNECT_TIMEOUT",
|
||||
}),
|
||||
}),
|
||||
];
|
||||
|
||||
for (const transientErr of transientCases) {
|
||||
@@ -119,6 +131,17 @@ describe("installUnhandledRejectionHandler - fatal detection", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("exits on non-transient Slack request errors", () => {
|
||||
const slackErr = Object.assign(
|
||||
new Error("A request error occurred: invalid request payload"),
|
||||
{
|
||||
code: "slack_webapi_request_error",
|
||||
},
|
||||
);
|
||||
|
||||
expectExitCodeFromUnhandled(slackErr, [1]);
|
||||
});
|
||||
|
||||
it("does not exit on AbortError and logs suppression warning", () => {
|
||||
const abortErr = new Error("This operation was aborted");
|
||||
abortErr.name = "AbortError";
|
||||
|
||||
@@ -49,6 +49,7 @@ const TRANSIENT_NETWORK_MESSAGE_CODE_RE =
|
||||
const TRANSIENT_NETWORK_MESSAGE_SNIPPETS = [
|
||||
"getaddrinfo",
|
||||
"socket hang up",
|
||||
"client network socket disconnected before secure tls connection was established",
|
||||
"network error",
|
||||
"network is unreachable",
|
||||
"temporary failure in name resolution",
|
||||
|
||||
Reference in New Issue
Block a user