Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property '0' of undefined #18

Open
guillemcordoba opened this issue Jun 21, 2021 · 5 comments
Open

Cannot read property '0' of undefined #18

guillemcordoba opened this issue Jun 21, 2021 · 5 comments

Comments

@guillemcordoba
Copy link

When calling a zome function, this error occurs:

inline-module-index-1.js:9053 Uncaught TypeError: Cannot read property '0' of undefined
    at ParentAPI.<anonymous> (inline-module-index-1.js:9053)
    at ParentAPI.listener (inline-module-index-1.js:8904)

following the trail it's because of this line:

let [k, v] = data;
, where data seems to be undefined.

This is a bit weird, because the app continues to work, and all the zome functions that we call do return something.

@timotree3
Copy link
Contributor

I am guessing the exception is on this line

const fn = this.methods[method];

@timotree3
Copy link
Contributor

I don't think the exception can come from the destructuring assignment you linked because in Chromium, destructuring undefined gives:

Uncaught TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))

and indexing undefined gives

Uncaught TypeError: Cannot read property '0' of undefined

@guillemcordoba
Copy link
Author

Hum this is interesting... This is the actual executing minified js:

                        child.on('response', function (data) {
                            var k = data[0], v = data[1];
                            // log.info("Received response for msg_id:", k );
                            var _a = _this.responses[k], f = _a[0], r = _a[1];
                            if (v instanceof Error)
                                r(v);
                            else
                                f(v);
                            delete _this.responses[k];

And I thought that the data[0] was the problem.

@timotree3
Copy link
Contributor

Gotcha. That seems to imply that .emit("response", undefined) is called on a ParentAPI somewhere, but every single instance of "response" is accompanied by an array of length 2. I don't see how this error could possibly be happening

@guillemcordoba
Copy link
Author

Yeah I don't know... I did a console.log on data and it never showed undefined. But still this is what I'm getting... Let's see if others get the same when this becomes more used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants