Skip to content

fix(connector): use native AbortController instead of bundled polyfill - #1327

Open
kib35576 wants to merge 1 commit into
TraderAlice:devfrom
kib35576:fix/connector-abort-signal-packaging
Open

fix(connector): use native AbortController instead of bundled polyfill#1327
kib35576 wants to merge 1 commit into
TraderAlice:devfrom
kib35576:fix/connector-abort-signal-packaging

Conversation

@kib35576

@kib35576 kib35576 commented Sep 3, 2026

Copy link
Copy Markdown

Problem

The Telegram (and Discord) connector never reaches a healthy polling session on a freshly built image. Both .cjs and the packaged runtime show a perpetual degraded loop with:

Telegram polling session did not become ready within 30000ms

Root cause

grammY's Node shim (shim.node.js) imports the legacy abort-controller polyfill. The connector bundle inlines everything (noExternal), so esbuild packs that polyfill in. esbuild renames the polyfill's AbortSignal class to AbortSignal2 to avoid colliding with the native global, and node-fetch v2 (v2.7.0) gates every request on:

Object.getPrototypeOf(signal).constructor.name === "AbortSignal"

The renamed class no longer matches, so every grammY HTTP call fails with Expected signal to be an instanceof AbortSignal, and long polling never becomes ready.

Outside the bundle (plain node_modules resolution) the polyfill class keeps its real name, so the failure only appears in the packaged connector — which is why it is easy to miss in dev/test but breaks deployed images.

Fix

Alias abort-controller (in services/connector/tsup.config.ts) to a small shim that re-exports Node's native AbortController/AbortSignal (runtime is Node >= 22). This drops the legacy polyfill from the bundle and hands node-fetch a native AbortSignal whose constructor keeps its real name.

Verification

  • services/connector typecheck + 122 tests pass (incl. 3 new shim specs)
  • root tsc --noEmit passes
  • Rebuilt connector.cjs and ran it against a real Telegram bot: reaches healthy and links the owner

grammY's Node shim imports the legacy abort-controller polyfill, which the
connector bundle inlines via noExternal. esbuild renames the polyfill's
AbortSignal class to avoid colliding with the native global, and node-fetch
v2 gates every request on the signal prototype's constructor name being
exactly "AbortSignal". The renamed class no longer matches, so every
grammY call fails with "Expected signal to be an instanceof AbortSignal"
and Telegram/Discord polling never becomes ready.

Alias abort-controller to a shim that re-exports Node's native globals
(runtime is Node >= 22), and cover it with a spec.
@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

@luokerenx4 is attempting to deploy a commit to the luokerenx4's Team Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants