Vercel Edge Runtime + Supabase + Drizzle, 15 seconds server lags + Trpc

When deploying on vercel with lambda everything is extra smooth. With vercel edge runtime a lot of things are not quite working One of those things are my transactions. The db < - > server trip is very fast. but the server < - > client takes 15seconds + Am I doing something wrong with this transaction?
await ctx.db.transaction(async (db) => {
const board = await db
.insert(boards)
.values({
name: input.name,
twitchUsername: input.twitchUsername,
youtubeChannelId: input.youtubeChannelId,
id: input.id,
slug: input.slug,
})
.returning();

console.timeLog("addNewBoard", { board });
const newValue = board[0] || null;

if (!newValue) {
db.rollback();

return "success";
}

await db.insert(boardOwnerships).values({
boardId: newValue.id,
profileId: ctx.user.id,
});
console.timeLog("addNewBoard", "board query done");

return "success";
});
console.timeEnd("addNewBoard");

return "success";
await ctx.db.transaction(async (db) => {
const board = await db
.insert(boards)
.values({
name: input.name,
twitchUsername: input.twitchUsername,
youtubeChannelId: input.youtubeChannelId,
id: input.id,
slug: input.slug,
})
.returning();

console.timeLog("addNewBoard", { board });
const newValue = board[0] || null;

if (!newValue) {
db.rollback();

return "success";
}

await db.insert(boardOwnerships).values({
boardId: newValue.id,
profileId: ctx.user.id,
});
console.timeLog("addNewBoard", "board query done");

return "success";
});
console.timeEnd("addNewBoard");

return "success";
1. When I remove the transaction and write the same code without it, it works as expected 2. Works perfectly on lambda 3. works perfectly locally
M
Mykhailo43d ago
Hello, @Jaaneek! You should use db instead of ctx.db here
No description
J
Jaaneek43d ago
Ohh sorry, I copy pasted it with a mistake. I had db.insert in there before. Still the same problem Edit: fixed it in the example
No description
J
Jaaneek43d ago
@solo can you spot any other mistakes? ❤️
M
Mykhailo43d ago
@Jaaneek honestly, I can't spot any mistakes then:))
J
Jaaneek43d ago
Yeah I think supabase & edge vercel are just not ready to work together and something in drizzle transaction breaks them 😦 Thanks for checking it out!
Want results from more Discord servers?
Add your server
More Posts
Can I use "where" clause on joins ?Hello ! I'm trying to query some data based on conditions. I know how to do it in prisma but I don'Is it possible to select 1 row?Seems an annoying oversight that I have to implement variable[0] everytime, even though I'm matchingget table's CREATE sql with DrizzleHello, does anyone know if it's possible to get a table's create sql with Drizzle? Would like to makCreate index in DESC orderConsider this schema: ```ts export const contactFormSubmission = pgTable( 'contact_form_submissioThe optimise likes tableI am beginner, i have lealearned about social media design pattern, i created posts, likes, commentsWhy fields with default value is nullableConsider this schema: ```ts export const blogMetadata = pgTable('blog_metadata', { id: varchar('id[SQLite Expo driver] Error code : no such table: task_to_tags``` Error: Call to function 'NativeDatabase.prepareSync' has been rejected. → Caused by: Error code Missing module "pg-core" when attempting to push?Title says most of it. I can provide details, but I'm following the example pretty closely.Executing database migrations on Vercelnow planetscale is removing their free tier, i'm looking to move, which probably means i gotta use mIs there a way to set foreign key on a bulk insert?Apologies if this is a stupid question but I need to know if I'm missing something obvious. I have tonConflict or upsert?i have a table where email is a unique field. if im trying to insert into the table and the email isIf we're using Drizzlekit push, do we need to ever generate migrations?Is there anywhere I can explain what the migration scripts are for? When I push a change, can't we j