Skip to content

Commit 1f4f55f

Browse files
committed
fix(telegram): add EAFNOSUPPORT to local-socket-failure codes and add regression test
LOCAL_SOCKET_FAILURE_MESSAGE_PATTERN extracts EAFNOSUPPORT from message text, but LOCAL_SOCKET_FAILURE_ERROR_CODES only contained EADDRNOTAVAIL. This mismatch meant a message-only EAFNOSUPPORT envelope would have ctx.codes non-empty without triggering the local-socket-failure guard, silently blocking the fallback without emitting the diagnostic warn — a classification gap that changes Telegram retry behavior. Add EAFNOSUPPORT to LOCAL_SOCKET_FAILURE_ERROR_CODES so the guard and message parser are aligned, and add a message-only EAFNOSUPPORT regression test asserting fallback=false and diagnostic warn emitted. Closes #94620
1 parent 4d33774 commit 1f4f55f

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

extensions/telegram/src/fetch.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,17 @@ describe("shouldRetryTelegramTransportFallback", () => {
13651365
expectLoggerMessageContaining(loggerWarn, "local socket allocation failure");
13661366
});
13671367

1368+
it("does not trigger IP-rotation fallback for EAFNOSUPPORT embedded only in the message", () => {
1369+
// EAFNOSUPPORT is also a local address-family failure — the kernel cannot
1370+
// assign a source address for the requested family. Like EADDRNOTAVAIL,
1371+
// rotating to an alternative Telegram IP cannot fix it.
1372+
const err = new TypeError("fetch failed: connect EAFNOSUPPORT 149.154.167.220:443 - Local (:::0)");
1373+
1374+
expect(shouldRetryTelegramTransportFallback(err)).toBe(false);
1375+
expectNoLoggerMessageContaining(loggerWarn, "fetch fallback: DNS-resolved IP unreachable");
1376+
expectLoggerMessageContaining(loggerWarn, "local socket allocation failure");
1377+
});
1378+
13681379
it("still retries for remote-reachability errnos that IP rotation can fix", () => {
13691380
const err = buildFetchFallbackError("EHOSTUNREACH");
13701381
expect(shouldRetryTelegramTransportFallback(err)).toBe(true);

extensions/telegram/src/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const FALLBACK_RETRY_ERROR_CODES = [
131131
// IP cannot fix these (the kernel cannot assign a source address/port for any
132132
// destination), so falling back through the pinned-IP dispatcher is dead code
133133
// that only produces misleading "Telegram is down" log noise during an incident.
134-
const LOCAL_SOCKET_FAILURE_ERROR_CODES = ["EADDRNOTAVAIL"] as const;
134+
const LOCAL_SOCKET_FAILURE_ERROR_CODES = ["EADDRNOTAVAIL", "EAFNOSUPPORT"] as const;
135135

136136
// Errno tokens may appear only inside the error `message` when undici wraps a
137137
// connect failure as `fetch failed` without propagating `.code` onto the cause

0 commit comments

Comments
 (0)