Skip to content

Commit b8e2dba

Browse files
committed
fix(telegram): add UND_ERR_CONNECT_TIMEOUT to PRE_CONNECT_ERROR_CODES
UND_ERR_CONNECT_TIMEOUT occurs during TCP/TLS connect handshake, before any HTTP request data is sent. Adding it to the pre-connect set allows isSafeToRetrySendError to safely retry sendMessage when undici's connect timeout fires — the message was never transmitted.
1 parent 084cf2a commit b8e2dba

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

extensions/telegram/src/network-errors.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ describe("isSafeToRetrySendError", () => {
239239
["ECONNRESET", "read ECONNRESET", false],
240240
["ETIMEDOUT", "connect ETIMEDOUT", false],
241241
["EPIPE", "write EPIPE", false],
242-
["UND_ERR_CONNECT_TIMEOUT", "connect timeout", false],
242+
["UND_ERR_CONNECT_TIMEOUT", "connect timeout", true],
243243
])("returns %s => %s", (code, message, expected) => {
244244
expect(isSafeToRetrySendError(errorWithCode(message, code))).toBe(expected);
245245
});

extensions/telegram/src/network-errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const PRE_CONNECT_ERROR_CODES = new Set([
4747
"ENETDOWN", // Local network interface is down before connect completes (never sent)
4848
"ENETUNREACH", // No route to host (never sent)
4949
"EHOSTUNREACH", // Host unreachable (never sent)
50+
"UND_ERR_CONNECT_TIMEOUT", // TCP/TLS connect timeout (request never sent)
5051
]);
5152

5253
const RECOVERABLE_ERROR_NAMES = new Set([

0 commit comments

Comments
 (0)