fix(connector): use native AbortController instead of bundled polyfill - #1327
Open
kib35576 wants to merge 1 commit into
Open
fix(connector): use native AbortController instead of bundled polyfill#1327kib35576 wants to merge 1 commit into
kib35576 wants to merge 1 commit into
Conversation
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.
|
@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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Telegram (and Discord) connector never reaches a healthy polling session on a freshly built image. Both
.cjsand the packaged runtime show a perpetual degraded loop with:Root cause
grammY's Node shim (
shim.node.js) imports the legacyabort-controllerpolyfill. The connector bundle inlines everything (noExternal), so esbuild packs that polyfill in. esbuild renames the polyfill'sAbortSignalclass toAbortSignal2to avoid colliding with the native global, and node-fetch v2 (v2.7.0) gates every request on: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_modulesresolution) 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(inservices/connector/tsup.config.ts) to a small shim that re-exports Node's nativeAbortController/AbortSignal(runtime is Node >= 22). This drops the legacy polyfill from the bundle and hands node-fetch a nativeAbortSignalwhose constructor keeps its real name.Verification
services/connectortypecheck + 122 tests pass (incl. 3 new shim specs)tsc --noEmitpassesconnector.cjsand ran it against a real Telegram bot: reacheshealthyand links the owner