From 6186f620d29ffa592fa11b379cd76fa757032e54 Mon Sep 17 00:00:00 2001 From: George Kalogirou Date: Mon, 23 Feb 2026 01:22:02 +0200 Subject: [PATCH] fix(telegram): use manual signal forwarding to avoid cross-realm AbortSignal AbortSignal.any() fails in Node.js when signals come from different module contexts (grammY's internal signal vs local AbortController), producing: "The signals[0] argument must be an instance of AbortSignal. Received an instance of AbortSignal". Replace with manual event forwarding that works across all realms. Co-Authored-By: Claude Opus 4.6 --- src/telegram/bot.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/telegram/bot.ts b/src/telegram/bot.ts index b7bb8c34e60..24decd85670 100644 --- a/src/telegram/bot.ts +++ b/src/telegram/bot.ts @@ -119,6 +119,9 @@ export function createTelegramBot(opts: TelegramBotOptions) { // Cast baseFetch to global fetch to avoid node-fetch ↔ global-fetch type divergence; // they are runtime-compatible (the codebase already casts at every fetch boundary). const callFetch = baseFetch as unknown as typeof globalThis.fetch; + // Use manual event forwarding instead of AbortSignal.any() to avoid the cross-realm + // AbortSignal issue in Node.js (grammY's signal may come from a different module context, + // causing "signals[0] must be an instance of AbortSignal" errors). finalFetch = ((input: RequestInfo | URL, init?: RequestInit) => { const controller = new AbortController(); const abortWith = (signal: AbortSignal) => controller.abort(signal.reason);