question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'name' of null

See original GitHub issue

First 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:closed
  • Created 7 years ago
  • Comments:65 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
n-clarkcommented, Apr 30, 2019

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.

1reaction
juliuszacommented, Jul 11, 2019

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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'name' of null - javascript - Stack Overflow
So my problem is that sometimes data.content[i].location.name returns an error saying cannot read property 'name' of null. for ( var ...
Read more >
Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
Read more >
TypeError: Cannot read property 'name' of null · Issue #2728
Version 7.20.4 seems to crash with the following error in a non-tsx file. yarn run v1.22.4 $ prettier packages/core/src/**/*.less --check ...
Read more >
Cannot read property 'name' of null - when running queries or ...
I've got the new nav turned on. Now I see this error when I open some of my queries or opening my backlog....
Read more >
TypeError: Cannot read property 'name' of null at main on line
TypeError : Cannot read property 'name' of null at main on line ... I have been struggling with this for a while here....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found