-
Notifications
You must be signed in to change notification settings - Fork 122
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
Support Azure Functions v4 Model for webhookCallback
#737
Comments
Adds a new webook adapter following https://learn.microsoft.com/en-us/azure/azure-functions/functions-node-upgrade-v4 Fixes #737
Hi! Thanks for the kind words! Re-reading the code, I am actually surprised that grammY 1.34 works with v3. Isn't v3 supposed to have the request as the second argument? grammY/src/convenience/frameworks.ts Lines 276 to 291 in b04bfee
It looks like the order of context and request is wrong. That being said, we clearly need a new adapter to support v4. I opened #738 which should fix both issues. You can install it from GitHub via npm install github:grammyjs/grammY#support-azure-v4 Could you test the following two cases and confirm that they work?
|
Oh now I see it. You basically added a workaround that fixes the issue in grammY. That's why it did not crash on your end. This was never supposed to be necessary. |
@KnorpelSenf Thank you for your explanation. I now understand your points. In the current version of grammY (1.3.4), using the original Azure Functions v3 model might cause issues due to incorrect argument order. Somehow, with my framework, Nammatham, this can be resolved as it manually pass the arguments. For example:
Thank you so much for addressing the issue so quickly! I'm pleasantly surprised and excited about this progress. I'll now prepare a repository to test both the v3 and v4 adapters and will share the results with you once they are ready. |
@KnorpelSenf For v3 result test, I've successfully run grammY on locally, but I've found that the type of Here is the code for v3: https://github.com/mildronize/grammy-azure-functions-test/tree/main/func-v3 the type error is here: the full error:
the code that error found const telegramBot: AzureFunction = async function (
context: Context,
request: HttpRequest,
): Promise<void> {
await webhookCallback(bot, "azure")(context, request);
}; Type of Azure/Functions ContextAs you can see in the Official Azure Functions Code, https://github.com/Azure/azure-functions-nodejs-library/blob/v3.5.1/types/Context.d.ts#L11-L71, you will see the context is not match as the error occurs. And your context will be https://github.com/grammyjs/grammY/blob/support-azure-v4/src/convenience/frameworks.ts#L82-L94 SolutionI've created the PR that fix that of your and the result as show below |
Epic, thank you! |
@mildronize it's merged, can you confirm that the pull request #738 introduces the right changes now? |
@KnorpelSenf let's me test it on azure func v4 |
Problem in Type v4I've founded that type is incorrect in Azure Functions v4 (
After i've fixed typed, I can run them smoothly, I've tested locally and already deployed on Azure for Both v3, V4 Test Result for v3Test Result for v4SolutionDue to Azure Functions v4 type of After merge this PR, I think everything work fine both v3 and v4. |
Background
First of all, I’d like to thank the team behind grammy for creating such an amazing Telegram framework! I’ve enjoyed working with it, especially on my open-source bot using Cloudflare Workers.
Recently, I tried to use the
webhookCallback
feature with Azure Functions v4 (the latest official version of the Node.js runtime).However, I encountered an issue where Cloudflare Workers did not fully support Node.js APIs (details here). As a result, I returned to Azure Functions for deployment. After reviewing the
webhookCallback
interface, I found that it works well with the Azure Functions v3 model (as tested with the following code):Environment
Issue Summary
Thank you for taking the time to read this issue, and keep up the great work!
The text was updated successfully, but these errors were encountered: