mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:08:37 +00:00
fix: narrow Telegram failed-after retry match
This commit is contained in:
@@ -40,7 +40,7 @@ describe("isRecoverableTelegramNetworkError", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("skips broad message matches for send context", () => {
|
it("skips broad message matches for send context", () => {
|
||||||
const networkRequestErr = new Error("Network request for 'sendMessage' timed out!");
|
const networkRequestErr = new Error("Network request for 'sendMessage' failed!");
|
||||||
expect(isRecoverableTelegramNetworkError(networkRequestErr, { context: "send" })).toBe(false);
|
expect(isRecoverableTelegramNetworkError(networkRequestErr, { context: "send" })).toBe(false);
|
||||||
expect(isRecoverableTelegramNetworkError(networkRequestErr, { context: "polling" })).toBe(true);
|
expect(isRecoverableTelegramNetworkError(networkRequestErr, { context: "polling" })).toBe(true);
|
||||||
|
|
||||||
@@ -49,12 +49,7 @@ describe("isRecoverableTelegramNetworkError", () => {
|
|||||||
expect(isRecoverableTelegramNetworkError(undiciSnippetErr, { context: "polling" })).toBe(true);
|
expect(isRecoverableTelegramNetworkError(undiciSnippetErr, { context: "polling" })).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("treats grammY network envelope errors as recoverable in send context", () => {
|
it("treats grammY failed-after envelope errors as recoverable in send context", () => {
|
||||||
expect(
|
|
||||||
isRecoverableTelegramNetworkError(new Error("Network request for 'sendMessage' failed!"), {
|
|
||||||
context: "send",
|
|
||||||
}),
|
|
||||||
).toBe(true);
|
|
||||||
expect(
|
expect(
|
||||||
isRecoverableTelegramNetworkError(
|
isRecoverableTelegramNetworkError(
|
||||||
new Error("Network request for 'sendMessage' failed after 2 attempts."),
|
new Error("Network request for 'sendMessage' failed after 2 attempts."),
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ const RECOVERABLE_ERROR_NAMES = new Set([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const ALWAYS_RECOVERABLE_MESSAGES = new Set(["fetch failed", "typeerror: fetch failed"]);
|
const ALWAYS_RECOVERABLE_MESSAGES = new Set(["fetch failed", "typeerror: fetch failed"]);
|
||||||
const GRAMMY_NETWORK_REQUEST_FAILED_RE =
|
const GRAMMY_NETWORK_REQUEST_FAILED_AFTER_RE =
|
||||||
/^network request(?:\s+for\s+["']?[^"']+["']?)?\s+failed(?:\s+after\b.*)?[!.]?$/i;
|
/^network request(?:\s+for\s+["']?[^"']+["']?)?\s+failed\s+after\b.*[!.]?$/i;
|
||||||
|
|
||||||
const RECOVERABLE_MESSAGE_SNIPPETS = [
|
const RECOVERABLE_MESSAGE_SNIPPETS = [
|
||||||
"undici",
|
"undici",
|
||||||
@@ -108,7 +108,7 @@ export function isRecoverableTelegramNetworkError(
|
|||||||
if (message && ALWAYS_RECOVERABLE_MESSAGES.has(message)) {
|
if (message && ALWAYS_RECOVERABLE_MESSAGES.has(message)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (message && GRAMMY_NETWORK_REQUEST_FAILED_RE.test(message)) {
|
if (message && GRAMMY_NETWORK_REQUEST_FAILED_AFTER_RE.test(message)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (allowMessageMatch && message) {
|
if (allowMessageMatch && message) {
|
||||||
|
|||||||
Reference in New Issue
Block a user