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 'unwrapObject' of undefined

See original GitHub issue

It appears with the new version, 30 (I guess starting from 27). It depends on the doc returned, if it contains array of maps or other particular nested structure, it crashes. With a “standard” doc, so without nested object, it works. Works fine until version 26.

Minimal code to reproduce the problem

const firestore = FirestoreApp.getFirestore(email, key, projectId);
firestore.query('carts').orderBy('lastUpdate', 'desc').limit(10000).execute();

Expected Behavior

documents[0].obj; // This returns raw object.

Actual Results

documents[0].obj; 
// TypeError: Cannot read property 'unwrapObject' of undefined
//  at unwrapValue(Document:62:29)
//   at unwrapArray(Document:79:29)
//   at unwrapValue(Document:64:29)
//   at [unknown function](Document:74:31)
//   at unwrapObject(Document:73:49)
//   at get obj(Document:42:25)
Library Version:

30

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
LaughDonorcommented, Jun 25, 2020

@marcolong I see the issue. I misunderstood the problem. I got thrown off because you were using the .query functionality. But it was all about unwrapping a nested object. I’ll work on this.

1reaction
LaughDonorcommented, Jun 25, 2020

As stated in the Breaking Changes:

Query function names have been capitalized (Select, Where, OrderBy, Limit, Offset, Range).

This change was to avoid conflicts with Firestore Typing documentation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError: Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an undefined...
Read more >
Uncaught typeError: Cannot read property of undefined - object
I've looked at other questions w/ this error message the issue usually seems to be that javascript hasn't defined the variable yet. I...
Read more >
How to Prevent the Error: Cannot Read Property '0' of Undefined
A guide on how to prevent the error "cannot Read Property '0' of Undefined", covering techniques such as try, catch, using const over...
Read more >
How to Fix TypeError: Cannot read Property 'push' of ...
You call the method on a variable previously set to undefined . You call the method on a variable before it has been...
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