# Error - Cannot read property 'constructor' of null while using Neovis.js

**URL:** <https://community.neo4j.com/t/error-cannot-read-property-constructor-of-null-while-using-neovis-js/2456>\
**Category:** Cypher\
**Tags:** cypher, operations, import\
**Created:** [October 15, 2018, 7:00am UTC](https://community.neo4j.com/t/error-cannot-read-property-constructor-of-null-while-using-neovis-js/2456 "2018-10-15T07:00:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sucheta](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/sucheta/32/4444_2.png) [@sucheta](https://community.neo4j.com/u/sucheta)\
**Post date:** [October 15, 2018, 7:00am UTC](https://community.neo4j.com/t/error-cannot-read-property-constructor-of-null-while-using-neovis-js/2456/1 "2018-10-15T07:00:38Z")

</div>

**Information** :

- neo4j version - 3.4.7 Enterprise,  
browser version - Version 3.4.7
- what kind of API / driver do you use - I am using Neovis.js

With cypher query -  
var cypherQuery =

```
  "MATCH (n) OPTIONAL MATCH (n)-[r]-&gt;(m) RETURN n,r,m LIMIT 10";

```

**I get proper response** -

 ![neovis-1](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/2X/2/26abc7ad5026bfa8ed08c55ef9837240431a42b0.png)

**Issue - I get an error message**  
ERROR TypeError: Cannot read property 'constructor' of null

when my Limit in the cypher query increases beyond 10.

(say )- var cypherQuery =

```
     "MATCH (n) OPTIONAL MATCH (n)-[r]-&gt;(m) RETURN n,r,m LIMIT 15";

```

**complete log of error -**

ERROR TypeError: Cannot read property 'constructor' of null  
at neovis.js:36514  
at Record.forEach (neovis.js:33630)  
at Object.onNext (neovis.js:36511)  
at \_RunObserver.onNext (neovis.js:33014)  
at Connection.\_handleMessage (neovis.js:31442)  
at Dechunker.Connection.\_dechunker.onmessage (neovis.js:31392)  
at Dechunker.\_onHeader (neovis.js:30537)  
at Dechunker.AWAITING\_CHUNK (neovis.js:30490)  
at Dechunker.write (neovis.js:30548)  
at WebSocketChannel.self.\_ch.onmessage (neovis.js:31365)

Please help.

**Source code -**

```
    const url = 'bolt://localhost:11001';
    const username = 'neo4j';
    const password = 'Viralabc';
     const encrypted = true;

   var cypherQuery = "MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 15";

   var config = {
    container_id: "viz",
    server_url: "bolt://localhost:11001",
    server_user: "neo4j",
    server_password: "Virtuallib1",
    labels: {
     
        "Banking": {
            "caption": "name",
            "size": "pagerank",
            "community": "community"
           
        }
      },
       relationships: {
          "cc": {
            "thickness": "weight",
            "caption": false
         }
        },
   
        initial_cypher:cypherQuery ,        
        arrows: true,
        hierarchical_layout:true,
         hierarchical_sort_method:"directed",
   
     };                 
     this.viz = new NeoVis.default(config);  

     this.viz.render();
     console.log(this.viz);
```

---

<div class="post-metadata">

**Author:** ![lyonwj](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/lyonwj/32/27358_2.png) [@lyonwj](https://community.neo4j.com/u/lyonwj)\
**Post date:** [October 15, 2018, 12:44pm UTC](https://community.neo4j.com/t/error-cannot-read-property-constructor-of-null-while-using-neovis-js/2456/2 "2018-10-15T12:44:01Z")

</div>

I'm not certain, but it looks like neovis.js may not be properly handling nulls returned in the Cypher query as a result of using `OPTIONAL MATCH`.

Could you please create a Github issue here and we will investigate further and fix: [Issues · neo4j-contrib/neovis.js · GitHub](https://github.com/neo4j-contrib/neovis.js/issues)

---

<div class="post-metadata">

**Author:** ![sucheta](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/sucheta/32/4444_2.png) [@sucheta](https://community.neo4j.com/u/sucheta)\
**Post date:** [October 16, 2018, 4:00am UTC](https://community.neo4j.com/t/error-cannot-read-property-constructor-of-null-while-using-neovis-js/2456/3 "2018-10-16T04:00:29Z")

</div>

Hi William,

I have included the issue in github . Link -

> <https://github.com/neo4j-contrib/neovis.js/issues/40>
>
> Information:
> 
> neo4j version - 3.4.7 Enterprise,
> browser version - Version 3.4….7
> what kind of API / driver do you use - I am using Neovis.js
> With cypher query -
> var cypherQuery =
> 
> "MATCH (n) OPTIONAL MATCH (n)-\[r\]-\>(m) RETURN n,r,m LIMIT 10";
> 
> \*\*I get proper response -\*\*
> 
> !\[neovis-1\](https://user-images.githubusercontent.com/37062796/46991410-7b731400-d123-11e8-9e0f-eb9df0025914.png)
> 
> \*\*Issue is - I get an error message\*\*
> 
> ERROR TypeError: Cannot read property 'constructor' of null
> 
> when my Limit in the cypher query increases beyond 10.
> 
> (say )- var cypherQuery =
> 
> "MATCH (n) OPTIONAL MATCH (n)-\[r\]-\>(m) RETURN n,r,m LIMIT 15";
> 
> \*\*complete log of error -\*\*
> 
> ERROR TypeError: Cannot read property 'constructor' of null
> at neovis.js:36514
> at Record.forEach (neovis.js:33630)
> at Object.onNext (neovis.js:36511)
> at \_RunObserver.onNext (neovis.js:33014)
> at Connection.\_handleMessage (neovis.js:31442)
> at Dechunker.Connection.\_dechunker.onmessage (neovis.js:31392)
> at Dechunker.\_onHeader (neovis.js:30537)
> at Dechunker.AWAITING\_CHUNK (neovis.js:30490)
> at Dechunker.write (neovis.js:30548)
> at WebSocketChannel.self.\_ch.onmessage (neovis.js:31365)
> 
> Please help.
> 
> 
> \*\*Source code -\*\*
> 
> const url = 'bolt://localhost:11001';
> const username = 'neo4j';
> const password = 'Vab1';
> const encrypted = true;
>  
> MATCH (n) OPTIONAL MATCH (n)-\[r\]-\>(m) RETURN n,r,m LIMIT 30
> 
> var cypherQuery = "";
>  
> var config = {
> container\_id: "viz",
> server\_url: "bolt://localhost:11001",
> server\_user: "neo4j",
> server\_password: "Vr123",
> labels: {
>         
> "Banking": {
> "caption": "name",
> "size": "pagerank",
> "community": "community"
>                
> }
> },
> relationships: {
> "cc": {
> "thickness": "weight",
> "caption": false
> }
> },
> RETURN cc",
>  
> initial\_cypher: cypherQuery ,        
> arrows: true,
> hierarchical\_layout:true,
> hierarchical\_sort\_method:"directed",
>        
> };                 
> this.viz = new NeoVis.default(config);  
>  
> this.viz.render();
> console.log(this.viz);
> }

---

<div class="post-metadata">

**Author:** ![lyonwj](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/lyonwj/32/27358_2.png) [@lyonwj](https://community.neo4j.com/u/lyonwj)\
**Post date:** [October 16, 2018, 9:21pm UTC](https://community.neo4j.com/t/error-cannot-read-property-constructor-of-null-while-using-neovis-js/2456/4 "2018-10-16T21:21:55Z")

</div>

Great - thanks! Let's track the problem there and I'll try to get it fixed soon, I think I see what is going on.

---

<div class="post-metadata">

**Author:** ![lyonwj](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/lyonwj/32/27358_2.png) [@lyonwj](https://community.neo4j.com/u/lyonwj)\
**Post date:** [October 16, 2018, 10:16pm UTC](https://community.neo4j.com/t/error-cannot-read-property-constructor-of-null-while-using-neovis-js/2456/6 "2018-10-16T22:16:53Z")

</div>


