TypeError: Cannot read property 'name' of null
See original GitHub issueFirst off, thanks for the library! Overall it’s been incredibly performant and straightforward to use. I am running into one issue which may be an issue with the library, though it’s a bit hard to follow the protocol for me so my usage may be off as well.
I’m running into an uncaught error during the parseComplete
handler in client.js (https://github.com/brianc/node-postgres/blob/v6.0.1/lib/client.js#L131).
I am doing a direct connect
against the pool and then utilizing pg-query-stream
pool.connect().then(function(client){
stream = client.query(new QueryStream(query, null));
stream.on('error', function(streamError){
stream.close(function(closeError){
// What to do with a close error? At this point stream is already hosed :shrug:
client.release(streamError);
}
});
stream.on('close', function(){
client.release();
});
});
At some point during my app’s life cycle, I get an uncaught error
TypeError: Cannot read property 'name' of null
at null.<anonymous> (/var/app/current/node_modules/pg/lib/client.js:139:26)
at emit (events.js:107:17)
at Socket.<anonymous> (/var/app/current/node_modules/pg/lib/connection.js:121:12)
at Socket.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at TCP.onread (net.js:540:20)
So obviously activeQuery
is becoming null, and I am trying to narrow down why I would receive a parseComplete
event when the active query is null.
According to my logs, the stream is not emitting an error, and seems to be closing normally. Therefore it seems like the connection client is getting a readyForQuery
or end
event, and then right after that getting the parseComplete
event. Any idea why this would be happening, or see any issues with my usage? Thanks for any help you can give! I’ll keep looking into it as well.
Issue Analytics
- State:
- Created 7 years ago
- Comments:65 (18 by maintainers)
Top GitHub Comments
Started getting this error after using the query_timeout config parameter, pg 7.10.0
Repro steps for me, using this config:
{ query_timeout: 10 * 1000, max: 32, min: 8 }
Steps: lock a table in the database and then issue queries against that table, so that they all time out; doesn’t have to be very fast, 1-2 per second will do. I get the crash very quickly, somewhere after around 10 to 100 query timeouts.
Other timing information, if it’s relevant: the database and node-postgres servers are on separate machines but the ping rtt is very low, 0.5 - 1ms.
I’m also using query_timeout:
[2019-07-11 09:36:36] [ERROR] [pid:8718] TypeError: Cannot read property ‘name’ of null TypeError: Cannot read property ‘name’ of null at Connection.<anonymous> (/opt/acn/4be1e1fb/api/node_modules/pg/lib/client.js:313:26) at emitOne (events.js:116:13) at Connection.emit (events.js:211:7) at Socket.<anonymous> (/opt/acn/4be1e1fb/api/node_modules/pg/lib/connection.js:126:12) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:597:20)