Closed hanahaneull closed 1 year ago
I cannot reproduce this. The below code works just fine.
type MyContext = Context & ConversationFlavor;
type MyConversation = Conversation<MyContext>;
export const bot = new Bot<MyContext>("");
bot.use(session({ initial: () => ({}) }));
bot.use(conversations());
async function convo(conversation: MyConversation, ctx: MyContext) {
await conversation.wait();
await ctx.reply("Does not crash?");
}
bot.use(createConversation(convo, "convo"));
bot.command("convo", (ctx) => ctx.conversation.enter("convo"));
bot.start();
I just found the issue, seems like I forgor to use await
on my next()
middleware.
Never thought the issue will be on middleware smh, since the code works without any wait()
or waitFor()
.
I wonder if we can somehow detect this problem and throw a more helpful error message than just crashing internally … forgetting to use await
correctly is a common oversight and it's desirable if not everyone has to perform the same investigation as you.
Using
.wait()
and.waitFor()
will crash the app after the conversation ended.Logs