Skip to content

Use Deno-native grammy to avoid node-fetch crash - #15

Merged
jihchi merged 1 commit into
mainfrom
fix/use-deno-native-grammy
Mar 2, 2026
Merged

Use Deno-native grammy to avoid node-fetch crash#15
jihchi merged 1 commit into
mainfrom
fix/use-deno-native-grammy

Conversation

@jihchi

@jihchi jihchi commented Mar 2, 2026

Copy link
Copy Markdown
Owner

Problem

The app crashes with:

TypeError: Cannot read properties of null (reading 'cancelHandleRid')
    at HttpsClientRequest.destroy (node:http:704:46)

This is caused by node-fetch@2.7.0 (a transitive dependency of the npm version of grammy) running through Deno's Node.js compatibility layer. When a network error triggers request abort, the compat layer's internal socket handle is already null.

Fix

  • Switch grammy from npm:grammy@^1 to deno.land/x/grammy@v1.41.0, which uses Deno's built-in fetch API instead of node-fetch
  • Add --allow-import to the cli task (required by grammy's Deno distribution for its cdn.skypack.dev dependency)

All tests pass.

@jihchi jihchi changed the title fix: use Deno-native grammy to avoid node-fetch crash Use Deno-native grammy to avoid node-fetch crash Mar 2, 2026
@jihchi
jihchi force-pushed the fix/use-deno-native-grammy branch 3 times, most recently from 2e56da6 to 10d7e4b Compare March 2, 2026 18:33
Switch grammy import from npm:grammy@^1 to deno.land/x/grammy@v1.41.0.

The npm version bundles node-fetch@2.7.0, which crashes on Deno with
'Cannot read properties of null (reading cancelHandleRid)' when the
Node.js compat layer tries to abort an HTTP request. The Deno-native
distribution uses the built-in fetch API instead.

Also adds --allow-import to the cli task, required by grammy's Deno
distribution for its cdn.skypack.dev dependency.
@jihchi
jihchi force-pushed the fix/use-deno-native-grammy branch from 10d7e4b to 92d7b3d Compare March 2, 2026 18:35
@jihchi
jihchi merged commit b7d2d9b into main Mar 2, 2026
2 checks passed
@jihchi
jihchi deleted the fix/use-deno-native-grammy branch March 2, 2026 18:36
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.

1 participant