Webhook timeout error
smatisen opened this issue · 2 comments
I`m using grammy with webhook on firebase functions hosting.
I use await conversation.wait() to get document from user. It works incosistent. Sometimes it triggers sometimes not. In terms of usability this is a disaster. Trying to fix that I used do while loop from manual. I have now timeout.error
Error: Request timed out after 10000 ms
at Timeout._onTimeout (/workspace/node_modules/grammy/out/convenience/webhook.js:55:24)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7)
Here is original logic before do while loop
await conversation.run(i18n);
await conversation.run(hydrate());
try {
await waitforme(1000);
statusMessage = await ctx.reply(ctx.t("valimised.wait"));
await waitforme(2000);
await statusMessage.editText(ctx.t("valimised.send"));
} catch (e) {
console.log(e);
return;
}
const myCtx = await conversation.wait();
if (!myCtx.message?.document) {
await waitforme(1000);
await statusMessage.editText(ctx.t("valimised.notAdocument"));
await waitforme(1000);
await myCtx?.message.delete();
await waitforme(1000);
await statusMessage.delete();
return;
}
await waitforme(1000);
await statusMessage.editText(ctx.t("valimised.uploading"));
What is waitforme(1000)
doing?
Note that it is not a good idea to delay update processing, so if that stuff just does a hard sleep, then your setup is very broken. See https://grammy.dev/guide/deployment-types.html#ending-webhook-requests-in-time
Did you maybe want to specify a maximum time to wait? See https://deno.land/x/grammy_conversations@v1.1.1/mod.ts?s=ConversationHandle
Closing due to inactivity.