-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make update
in webhook adapters a function
#697
Comments
We can wrap update with Promise.allSettled in framework handlers and gracefully stop Update processing. Like: update type: Promise<[PromiseSettledResult<Update>]> if (header !== secretToken) {
await unauthorized();
// TODO: investigate deno bug that happens when this console logging is removed
console.log(handlerReturn);
return handlerReturn;
}
const [updateData] = await update;
if (updateData.status === "rejected") {
await badRequest();
console.log(handlerReturn);
return handlerReturn;
}
let usedWebhookReply = false;
const webhookReplyEnvelope: WebhookReplyEnvelope = {
async send(json) {
usedWebhookReply = true;
await respond(json);
},
};
await timeoutIfNecessary(
bot.handleUpdate(updateData.value, webhookReplyEnvelope),
typeof onTimeout === "function"
? () => onTimeout(...args)
: onTimeout,
timeoutMilliseconds,
); Answer with bad request feels right, but we need to introduce this extra callback in every framework handler then. As an alternative, we can make update type Update Most of handlers will remove await c.req.json().catch(() => ({})) then we can check it in |
Is this related to the refactoring suggested in the issue description? |
Yep, will do a PQ an 5-10mins |
Using a function instead of a property for
update
lets use fix #613The text was updated successfully, but these errors were encountered: