Skip to content

firestore subscription throwing error on change #944

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

Closed
magicseth opened this issue Nov 15, 2020 · 6 comments
Closed

firestore subscription throwing error on change #944

magicseth opened this issue Nov 15, 2020 · 6 comments

Comments

@magicseth
Copy link

Reproduction

Magician
{{ spectators }}
<script> import { db } from "../db.js"; export default { data() { return { spectators: [], }; }, mounted() { db.collection("spectators") .get() .then(function (querySnapshot) { querySnapshot.forEach(function (doc) { console.log(doc); }); }); }, firestore: { spectators: db.collection("spectators"), }, }; </script>

Steps to reproduce the behavior

Open page

Expected behavior

show the spectators loaded from firestore.

Actual behavior

It throws an error:
Uncaught TypeError: Cannot convert undefined or null to object
at Function.keys ()
at extractRefs (vuefire.esm.js?0ff2:186)
at Object.added (vuefire.esm.js?0ff2:354)
at eval (vuefire.esm.js?0ff2:412)
at Array.forEach ()
at Array.eval (vuefire.esm.js?0ff2:411)
at next (index.esm.js?c6c5:16645)
at eval (index.esm.js?c6c5:13404)

@magicseth
Copy link
Author

In bindCollection(_a, extraOptions)

I am seeing that _a.newIndex == -1

Which means that subs ends up undefined.

var change = {
    added: function (_a) {
        var newIndex = _a.newIndex, doc = _a.doc;
        arraySubs.splice(newIndex, 0, Object.create(null));
        var subs = arraySubs[newIndex];
        var _b = extractRefs(options.serialize(doc), undefined, subs), data = _b[0], refs = _b[1];
        ops.add(array, newIndex, data);
        subscribeToRefs(options, array, newIndex, subs, refs, ops, 0, resolve.bind(null, doc));
    },

@magicseth
Copy link
Author

image

@magicseth
Copy link
Author

It seems like it's a problem with the latest firebase.js

Here's a repro:
https://jsfiddle.net/tsqvg9hf/2/

@khabali
Copy link

khabali commented Nov 15, 2020

i'm getting the same issue with the latest versions:

"vuefire": "^2.2.4"
"firebase": "^8.0.2",

when fetching a collection

vuefire.esm.js?0ff2:186 Uncaught TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at extractRefs (vuefire.esm.js?0ff2:186)
    at Object.added (vuefire.esm.js?0ff2:354)
    at eval (vuefire.esm.js?0ff2:412)
    at Array.forEach (<anonymous>)
    at Array.eval (vuefire.esm.js?0ff2:411)
    at next (index.esm.js?c6c5:16645)
    at eval (index.esm.js?c6c5:13404)

@magicseth
Copy link
Author

magicseth commented Nov 15, 2020 via email

@posva
Copy link
Member

posva commented Nov 16, 2020

#940

I haven't been able to look at this yet. Help on reviewing what has broken, if a new major version of vuefire should be released, and reviewing the PR would be appreciated

@posva posva closed this as completed Nov 16, 2020
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

3 participants