Next.js Discord

Discord Forum

Query just hangs/timesout

Unanswered
Thrianta posted this in #help-forum
Open in Discord
ThriantaOP
One of my drizzle queries just hangs in production.

await db.select().from(articlesTable)

This can be either for 10 seconds then timeout on Vercel, or it can be indefinitely on a custom Docker image. As a workaround I've replaced the query with a fetch request to Turso's http endpoint for my db.

await fetch(env.DATABASE_URL.replace("libsql", "https"), {method: "POST", headers: {Authorization: 'Bearer ${env.DATABASE_AUTH_TOKEN'}, body: JSON.stringify({statementes: ["select * from articles"]}).then(...)

It's weird because I can manually go to a known aritcle slug, eg /articles/1/travel-to-the-netherlands, and a very similar query will successfully get called. In fact this query is in the same queries.ts file as the one mentioned above.

await db.select().from(articlesTable).where(eq(articlesTable.id, articleId))

I tried limiting the number of articles returned in the get-all query to 1 with .limit(1) but it had no effect. I tried calling the query on different pages and they also timed out.

Any clues or suggestions on where to start debuging?

0 Replies