Investigate parameterized INSERT statements with RETURNING clauses using node-postgres.
When running this program using --parameterized --returning, we observe bad behavior like:
(node:14790) TypeError: Cannot read property 'name' of undefined
at Result.parseRow (/Users/amo/dev/crate/troubleshooting/npm-pg-001/node_modules/pg/lib/result.js:66:34)
at Query.handleDataRow (/Users/amo/dev/crate/troubleshooting/npm-pg-001/node_modules/pg/lib/query.js:87:26)
at Client._handleDataRow (/Users/amo/dev/crate/troubleshooting/npm-pg-001/node_modules/pg/lib/client.js:345:22)
at Connection.emit (events.js:315:20)
at /Users/amo/dev/crate/troubleshooting/npm-pg-001/node_modules/pg/lib/connection.js:115:12
at Parser.parse (/Users/amo/dev/crate/troubleshooting/npm-pg-001/node_modules/pg-protocol/dist/parser.js:40:17)
at Socket.<anonymous> (/Users/amo/dev/crate/troubleshooting/npm-pg-001/node_modules/pg-protocol/dist/index.js:10:42)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:284:9)
(node:14790) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:180:11)
at processPromiseRejections (internal/process/promises.js:249:13)
at processTicksAndRejections (internal/process/task_queues.js:94:32)
When running this program using --parameterized --returning --improve, the program occasionally succeeds,
but there is still flakyness oscillating between the error above, success and this error:
/Users/amo/dev/crate/troubleshooting/npm-pg-001/node_modules/pg/lib/client.js:345
this.activeQuery.handleDataRow(msg)
^
TypeError: Cannot read property 'handleDataRow' of null
at Client._handleDataRow (/Users/amo/dev/crate/troubleshooting/npm-pg-001/node_modules/pg/lib/client.js:345:22)
at Connection.emit (events.js:315:20)
at /Users/amo/dev/crate/troubleshooting/npm-pg-001/node_modules/pg/lib/connection.js:115:12
at Parser.parse (/Users/amo/dev/crate/troubleshooting/npm-pg-001/node_modules/pg-protocol/dist/parser.js:40:17)
at Socket.<anonymous> (/Users/amo/dev/crate/troubleshooting/npm-pg-001/node_modules/pg-protocol/dist/index.js:10:42)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:284:9)
at Socket.Readable.push (_stream_readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
When using the "native" driver through --parameterized --returning --native,
the program will always succeed.
- Using
--nativeis currently the best option. - Using
--binarydoes not have any influence. --improveis just a nasty workaround adding twoSELECT 1statements to the mix. This is obviously not a solution (the error nevertheless still happens anyway) but is here in order to demonstrate that the program succeeds sometimes. We can figure from this that the behavior somehow seems to depend on async timing details.