-
Notifications
You must be signed in to change notification settings - Fork 118
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
Crashing on calling webhook with empty JSON body using Oak #613
Comments
The code responsible for oak is here: grammY/src/convenience/frameworks.ts Lines 467 to 481 in fa10509
Are you able to fix this? |
I've got an idea how to fix it. I'll try fixing when i'll get some spare time. |
Thank you! |
I noticed a crash when sending a POST request with an empty body to the webhook using Hono. I figured out it was due to an uncaught exception from a promise. As a test, changing the code as follows resolves the crash: update: (async () => {
try {
return await c.req.json();
} catch (error) {
return {} as any;
}
})(), Such a request would likely be refused due to the A potential solution is changing the order in which webhookCallback handles promises: const { update, respond, unauthorized, end, handlerReturn, header } =
server(...args);
const receivedUpdate = await update;
// ...
await timeoutIfNecessary(
bot.handleUpdate(receivedUpdate, webhookReplyEnvelope),
typeof timeout === 'function' ? () => timeout(...args) : timeout,
ms
); This should fix the error for all frameworks. |
If somebody occasionally do an GET request to webhook endpoint it will result in entire server crashing.
See also oakserver/oak#661
The text was updated successfully, but these errors were encountered: