porsager / porsager/postgres

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

Open
#960 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
8.7k
Forks
374
Avg merge
11d 16h
Merged PRs (30d)
1

Description

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
  }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file or test is identified. Start by examining the postgres(env.DB_SUPABASE.connectionString) setup in xpto and the loop through doStuff, then investigate how the Cloudflare Hyperdrive connection handles the prepared statement error. Done means reproducing the failure and documenting a verified cause and resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, postgresql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.