node-postgres icon indicating copy to clipboard operation
node-postgres copied to clipboard

Question: should client.hasExecuted be reset?

Open alxndrsn opened this issue 3 years ago • 0 comments

I'm seeing https://github.com/brianc/node-postgres/issues/2168 frequently, and have bumped into https://github.com/brianc/node-postgres/issues/1872 occasionally.

#2168 seems to be caused by an out-of-order parseComplete message arriving, after this.activeQuery has already been set to null.

While digging around, I was intrigued by the property this.hasExecuted in client.js (https://github.com/brianc/node-postgres/blob/master/packages/pg/lib/client.js#L482). If I've understood correctly, the Client instance can be re-used for multiple queries, but hasExecuted is implicitly initialised to undefined, set to true just before the first call to this.activeQuery.submit(...), and never re-set to something falsy.

Does hasExecuted track that the Client instance has submitted at least one query? Or should it be tracking if the Client instance has submitted the current active query?

alxndrsn avatar Sep 21 '22 07:09 alxndrsn