From 79523e82b1dd0f780766fb33b53642ece92497b4 Mon Sep 17 00:00:00 2001 From: emad Date: Fri, 17 Apr 2026 20:17:34 +0300 Subject: [PATCH] fix: mention Bot API calls in `external` wait-rejection error 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 #148. --- src/conversation.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/conversation.ts b/src/conversation.ts index 8dafa19..cfa33df 100644 --- a/src/conversation.ts +++ b/src/conversation.ts @@ -253,7 +253,10 @@ export class Conversation< if (this.insideExternal) { throw new Error( "Cannot wait for updates from inside `external`, or concurrently to it! \ -First return your data from `external` and then resume update handling using `wait` calls.", +This also applies to Bot API calls (such as `ctx.api.getFile`, `ctx.reply`, \ +or chat actions) because they rely on `wait` internally, so perform \ +them outside of `external` instead. First return your data from `external` and \ +then resume update handling using `wait` calls.", ); } const makeWait = async () => {