mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 19:54:57 +00:00
fix(infra): treat nested network request errors as non-fatal
This commit is contained in:
committed by
Peter Steinberger
parent
445c7a65e6
commit
daaad03593
@@ -92,6 +92,30 @@ describe("isTransientNetworkError", () => {
|
||||
expect(isTransientNetworkError(error)).toBe(true);
|
||||
});
|
||||
|
||||
it("returns true for Slack request errors that wrap network codes in .original", () => {
|
||||
const error = Object.assign(new Error("A request error occurred: getaddrinfo EAI_AGAIN"), {
|
||||
code: "slack_webapi_request_error",
|
||||
original: {
|
||||
errno: -3001,
|
||||
code: "EAI_AGAIN",
|
||||
syscall: "getaddrinfo",
|
||||
hostname: "slack.com",
|
||||
},
|
||||
});
|
||||
expect(isTransientNetworkError(error)).toBe(true);
|
||||
});
|
||||
|
||||
it("returns true for network codes nested in .data payloads", () => {
|
||||
const error = {
|
||||
code: "slack_webapi_request_error",
|
||||
message: "A request error occurred",
|
||||
data: {
|
||||
code: "EAI_AGAIN",
|
||||
},
|
||||
};
|
||||
expect(isTransientNetworkError(error)).toBe(true);
|
||||
});
|
||||
|
||||
it("returns true for AggregateError containing network errors", () => {
|
||||
const networkError = Object.assign(new Error("timeout"), { code: "ETIMEDOUT" });
|
||||
const error = new AggregateError([networkError], "Multiple errors");
|
||||
@@ -109,6 +133,18 @@ describe("isTransientNetworkError", () => {
|
||||
expect(isTransientNetworkError(error)).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false for Slack request errors without network indicators", () => {
|
||||
const error = Object.assign(new Error("A request error occurred"), {
|
||||
code: "slack_webapi_request_error",
|
||||
});
|
||||
expect(isTransientNetworkError(error)).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false for non-transient undici codes that only appear in message text", () => {
|
||||
const error = new Error("Request failed with UND_ERR_INVALID_ARG");
|
||||
expect(isTransientNetworkError(error)).toBe(false);
|
||||
});
|
||||
|
||||
it.each([null, undefined, "string error", 42, { message: "plain object" }])(
|
||||
"returns false for non-network input %#",
|
||||
(value) => {
|
||||
|
||||
Reference in New Issue
Block a user