porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.46k stars 272 forks source link

[Cloudflare Hyperdrive] PostgresError: prepared statement "o0gtsdfu434" already exists #960

Open emerleite opened 2 weeks ago

emerleite commented 2 weeks ago

I'm looping over some array items and perform some DB tasks. It's basic Select and Inserts.

Somehow, I receive prepared statment already exists error.

I saw other issues people mentioning something related with pg_bouncer.

Any tips?

async function xpto(items) {
  const sql = postgres(env.DB_SUPABASE.connectionString)
  for (const item of items) {
    await doStuff(item, sql);
  }
}

async function doStuff(item, sql) {
  //Sometimes this and other thows `prepared statment already exists` error
  const checkSomething = await sql`SELECT * FROM table WHERE a_column = ${item.value};`
  if (checkSomething.a_column == 'something') {
     //Finish Work
  }
}
morpig commented 2 weeks ago

prepare: false in postgres.js config

emerleite commented 2 weeks ago

@morpig thanks. But how do I manual create it when it needed?