question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PgBouncer Error: prepared statement already exists

See original GitHub issue

I am getting a following error: You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection: error: prepared statement "public.rate_limiter:undefined" already exists.

It seems that the rejection happens during the creation of the limiter:

const rateLimiterHours1 = new RateLimiter.RateLimiterPostgres({
  storeClient: pool,
  points: 250,
  duration: 3600,// 1 hour
  tableName: 'public.rate_limiter',
  keyPrefix: 'limiter_hours_1',
});

And I consume this limiter only in one place where it has a catch:

rateLimiterUnion.consume(ip) // union of 1 RateLimiterMemory and 1 RateLimiterPostgres
  .then(_limiter => {
    next();
  })
  .catch((_err) => {
    console.log(_err)
    next(new HTTP429Error())
  });

Please feel free to let me know if if I can provide some additional details!

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
animircommented, Dec 18, 2022

Ok, thanks, I am closing this issue for now. I think, it is not related to this package. Feel free to reopen.

1reaction
animircommented, Dec 14, 2022

@harryn Thanks. I found a lot of similar issues with PGBouncer on the internet. Try pg prepared statement error or pgbouncer prepared statement already exists search. I don’t share any here, since you better know what exactly should be checked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Postgres - ERROR: prepared statement "S_1" already exists
This turned out to be a pgBouncer issue that occurs when using anything other than session pooling. We were using transaction pooling, which ......
Read more >
prepared statement \"s0\" already exists when connecting to ...
Bug description. I'm connecting to postgres on digital ocean with pgbouncer as guided here: https://www.prisma.io/docs/concepts/database ...
Read more >
prepared statement already exists - Google Groups
This is a cross-post to both pgbouncer and jooq lists, as I am unsure where in my stack I need to address this...
Read more >
pgbouncer/pgbouncer - Gitter
Caused by: org.postgresql.util.PSQLException: ERROR: prepared statement "S_2" already exists can you help me?
Read more >
Prepared statement already exists - PostgreSQL
I'm trying to use prepared statements in an application and I'm running into this error: "Query failed: prepared statement already exists".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found