node-pg-pool icon indicating copy to clipboard operation
node-pg-pool copied to clipboard

Is there a compelling reason to throw an exception when re-releasing a client?

Open kurtmilam opened this issue 7 years ago • 1 comments

Unless there's a compelling reason to throw when a developer calls client.release more than once, I'd prefer to see client.release mutate itself into a noop the first time it's called - that would be better for developer ergonomics.

Related question: Is there an easy way to determine whether a client has already been released (easier than wrapping client.release() in a try...catch block and ignoring the exception)?

kurtmilam avatar Dec 12 '18 18:12 kurtmilam

a compelling reason to throw when a developer calls client.release more than once

It’s a mistake and hiding mistakes is bad.

Related question: Is there an easy way to determine whether a client has already been released (easier than wrapping client.release() in a try...catch block and ignoring the exception)?

No, because the pool might return the same client again, as the same object. (It should probably be changed so it returns wrapped clients instead of direct client objects in the next major.)

charmander avatar Dec 13 '18 05:12 charmander