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

Possible error in Fruitdown? #12

Open
ssured opened this issue Feb 22, 2017 · 4 comments
Open

Possible error in Fruitdown? #12

ssured opened this issue Feb 22, 2017 · 4 comments

Comments

@ssured
Copy link

ssured commented Feb 22, 2017

In my logs I frequently get an error: TypeError: undefined is not an object (evaluating 'n.doc._rev=n.value.rev')

This error points to pouchdb.fruitdown.js which points me here:

// line 18284 of pouchdb.fruitdown.js 6.2.1
        function allDocsInner(data) {
          var doc = {
            id: metadata.id,
            key: metadata.id,
            value: {
              rev: winningRev$$1
            }
          };
          if (opts.include_docs) {
            doc.doc = data;
            doc.doc._rev = doc.value.rev;                     //// <--- this line errors
            if (opts.conflicts) {
              var conflicts = collectConflicts(metadata);
              if (conflicts.length) {
                doc.doc._conflicts = conflicts;
              }
            }
            for (var att in doc.doc._attachments) {
              if (doc.doc._attachments.hasOwnProperty(att)) {
                doc.doc._attachments[att].stub = true;
              }
            }
          }
          if (opts.inclusive_end === false && metadata.id === opts.endkey) {
            return next();
          } else if (deleted) {
            if (opts.deleted === 'ok') {
              doc.value.deleted = true;
              doc.doc = null;
            } else {
              /* istanbul ignore next */
              return next();
            }
          }
          results.push(doc);
          next();
        }
        if (opts.include_docs) {
          var seq = metadata.rev_map[winningRev$$1];
          stores.bySeqStore.get(formatSeq(seq), function (err, data) {
            allDocsInner(data); //// <--- this line looks suspicious, as it does not handle the err
          });
        }
        else {
          allDocsInner(); //// <--- this line looks very suspicious, as data will be undefined in allDocsInner()
        }
// line 18330

I'm trying to find the root cause, but I am having a hard time finding the source of this code. Can you maybe help where allDocsInner()is defined? It's in the build of fruitdown, but not in this repo. In PouchDB there's an allDocsInner() function too, but with a different signature.

My wild guess now is indexeddb throws some kind of an error, but that error is not handled. See in the source above where I added this line looks suspicious.

Hope you can help, thanks!

@nolanlawson
Copy link
Owner

What browser is this occurring on? And if you're looking for the source, it's in pouchdb itself: https://github.com/pouchdb/pouchdb/blob/e1af762edf8cefe87a97b56f1095c5ca04310b30/packages/node_modules/pouchdb-adapter-leveldb-core/src/index.js#L908

@nolanlawson
Copy link
Owner

If data is undefined it's probably a bug in Safari; supposedly all IDB bugs are fixed in Safari 10.1 but maybe a few more slipped through. Reason I say I doubt it's a bug in PouchDB is because that particular adapter passes the full PouchDB test suite against localstoragedown, fruitdown, memdown, and leveldown, so it seems unlikely to me

@ssured
Copy link
Author

ssured commented Feb 22, 2017

Thanks for pointing me to the source, couldn't find it using github search box.

I checked my logs, it's happening on ios mobile safari 10.2.1 and 10.0.2, using the fruitdown adapter, for at least 2 unrelated users. The answer of what is happening is probably in the err variable; I don't know how hard it is to throw an error here?

@nolanlawson
Copy link
Owner

You'd have to set a breakpoint and log the error to see what's going on; unfortunately throwing will do nothing because it's an async stack.

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