Skip to content

fix: mention Bot API calls in external wait-rejection error#150

Open
Dramex wants to merge 1 commit into
grammyjs:mainfrom
Dramex:fix/clarify-external-wait-error
Open

fix: mention Bot API calls in external wait-rejection error#150
Dramex wants to merge 1 commit into
grammyjs:mainfrom
Dramex:fix/clarify-external-wait-error

Conversation

@Dramex
Copy link
Copy Markdown
Contributor

@Dramex Dramex commented Apr 17, 2026

Closes #148.

The existing error tells the caller to return from `external` before `wait`ing, but the most common way users hit it is by making a Bot API call inside `external` — `ctx.api.getFile`, `ctx.reply`, chat actions, etc. Those funnel through `wait` internally, so the symptom is an obscure `wait` error from code that never called `wait` directly. The reporter on #148 and the maintainer both confirmed this is the root cause.

Extend the message to call out Bot API calls explicitly, so the fix is obvious without a reader needing to know `wait` is what powers API calls under the hood.

Test plan

  • `deno task test --no-check` — 11/11 suites pass (pre-existing `RequestInit.body` type-check issue on `main` is unrelated).
  • `deno fmt --check`
  • `deno lint`

The error thrown when `wait` is invoked inside `external` explains that
you must return from `external` first, but the most common way users hit
this is by calling `ctx.api.*` (e.g. `getFile`, `reply`, chat actions)
inside `external`. Those go through `wait` internally, so the symptom is
opaque: you get a `wait` error from code that never called `wait`.

Extend the message to call out Bot API calls explicitly so the fix is
obvious.

Closes grammyjs#148.
@Dramex Dramex force-pushed the fix/clarify-external-wait-error branch from 5cd4a3a to 79523e8 Compare May 15, 2026 15:18
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.

Clarify error: “Cannot wait for updates from inside external…” should mention Bot API calls

1 participant