Request timeout on Supabase Edge Functions
Opened this issue · 4 comments
Simply installing the plugin on Supabase will cause it to load indefinitely on each request and throw no error.
It was working before until recently I think.
Sample code for reproduction :
console.log(`Function "telegram-bot" up and running!`);
import {
Bot,
Context,
session,
webhookCallback,
} from "https://deno.land/x/grammy@v1.21.1/mod.ts";
import {
type ConversationFlavor,
conversations,
} from "https://deno.land/x/grammy_conversations@v1.2.0/mod.ts";
type MyContext = Context & ConversationFlavor;
const bot = new Bot<MyContext>(Deno.env.get("BOT_TOKEN") || "");
// Install the session plugin.
bot.use(session({
initial() {
// return empty object for now
return {};
},
}));
// Install the conversations plugin.
bot.use(conversations()); // comment this line and the whole app works fine
bot.command("start", (ctx) => ctx.reply("Welcome! Up and running."));
bot.command("ping", (ctx) => ctx.reply(`Pong! ${new Date()} ${Date.now()}`));
const handleUpdate = webhookCallback(bot, "std/http");
Deno.serve(async (req) => {
try {
return await handleUpdate(req);
} catch (err) {
console.error(err);
}
});
Is this the exact code you used? You didn't add a storage adapter or anything before deployment?
This is just some sample code I was try with to test and see if it was really the conversation plugin that was faulty. I had been using the plugin and was working fine until now. I am not sure what the problems was or what had changed but removing the conversation plugin seem to be the fix.
I had try to add some storage adapter and it still not working. I tested with both Supabase and RAM adapter.
const storage = supabaseAdapter({
supabase,
table: "bot_session", // table name
});
// Install the session plugin.
bot.use(session({
initial() {
// return empty object for now
return {};
},
storage,
// storage: new MemorySessionStorage(),
}));
I'll take that as a yes. Does that same code work locally?
I have exactly the same issue. Script above pasted by @hoching87 works fine if you run it locally with deno, but not on supabase (supabase also has local development setup).
Simply running it with deno run --allow-read --allow-write --allow-env --allow-net --allow-run scripts/test.ts
works.
Having said that there is still a type mismatch after new grammy version.