"Called end on pool more than once"
See original GitHub issueI’m getting an error “Called end on pool more than once” when I run close() on the pool when shutting down the application. I am doing it from the unhandledRejection handler to cleanly shut down in case of an unhandled rejection. But since this can be called more than once, close() is getting called more than once.
Is there any reason why this should cause an error? Can’t it just silently fail if called more than once? Isn’t calling it from a callback like unhandledRejection, which can get called many times, a standard use case?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:7
Top Results From Across the Web
Error: Called end on pool more than once at BoundPool.end
Where did you find an example of calling .finally(db.$pool.end); at the end of an API call? You are destroying the connection pool after...
Read more >node-postgres: struggling with this error - Reddit
Ever since I polluted my app with db.connect(async function(err, client, done)) in every middleware, my app hangs as I am navigating through ...
Read more >Pooling – node-postgres
To shut down a pool call pool.end() on the pool. This will wait for all checked-out clients to be returned and then shut...
Read more >pg.Pool.end JavaScript and Node.js code examples - Tabnine
release() { return this.pool.end(); ... Learn More. adv-img ... pgDb.end()) .then(async () => pgHandler.disconnect()) .then(async () => console.log('done')).
Read more >Connection pools - psycopg 3.1.8.dev1 documentation
Failing to call close() at the end of the program is not terribly bad: probably ... If more connections than the ones available...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Well, I wouldn’t consider it a feature that
pool.endcan be called more than once. If we assumepool.endto be closing connections, it doesn’t make sense that it can be called more than once, since that’s not how connections work in general. IMO it’s doing exactly the right thing, throwing an error if it’s called multiple times, and that the inverse would be a bug.If there are cases that cause it to be called more than once on your application, then it makes more sense to handle that there. If anything, your code will serve as documentation for why
pool.endis called multiple times.I see, then I guess my earlier question remains: