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

Client.query(config, values, callback) sets config.callback, causing subsequent invocations to fail

Open christerswahn opened this issue 4 years ago • 3 comments

Client.query(), when using promises (no callback), will via normalizeQueryConfig() set config.callback, which causes subsequent invocations of Client.query() with the same config to fail silently - no error message, just returning undefined.

Passed config should never be modified, this is a client-owned object.

Functions such as this should never fail silently - either return a valid value / defined error value, or raise exception.

Note: Using version 8.5.1, via TypeScript "@types/pg": "^7.14.9".

christerswahn avatar Nov 10 '21 18:11 christerswahn

Passed config should never be modified, this is a client-owned object.

I agree with you. Do you have code to reproduce this? I can fix p quick.

brianc avatar Nov 15 '21 19:11 brianc

Wanted to bump this, I'm seeing very similar behavior. I was switching from callbacks to promises and noticed client.query() began returning undefined periodically instead of returning a promise.

jbilous avatar Mar 01 '22 04:03 jbilous

Wanted to bump this, I'm seeing very similar behavior. I was switching from callbacks to promises and noticed client.query() began returning undefined periodically instead of returning a promise.

Same here, I would love to see this fixed, as the issue heavily breaks my projects using this.

luni-moon avatar Apr 15 '22 14:04 luni-moon