Skip to content

[indexeddb] RFC: rev_tree can cause RangeError #8398

@jlami

Description

@jlami

Issue

A document with many revisions (500+) can lead to a RangeError exception while trying to store it in indexeddb.

Info

IndexedDB in Windows Chrome

Reproduce

https://bugs.chromium.org/p/chromium/issues/detail?id=1263612 shows how a document resembling a long rev_tree will fail

Options

Ignore

We could ignore this problem and decide that anybody that runs into this problem should start the PouchDB with a lower revs_limit manually or set the default revs_limit (which currently is 1000) to a lower value to prevent the issue from occurring

safeJsonStringify

We could use https://github.com/pouchdb/pouchdb/blob/a33bc407407f97b9f2382db364f9e49a0fa03b62/packages/node_modules/pouchdb-json/src/safeJsonStringify.js#L3 like the idb adapter also does

Rewrite rev_tree to not be so deep

I'm not sure how rev_tree is used, but maybe it might be an option to change the way we store the chain to not be as deep? I don't know if we really need this tree like structure, or if a flat array could work. But I'm not familiar enough with the code to say whether we really need the branching nature of a tree.

If we do need a tree, we might consider storing it in a different way? Store the branch points separately in a tree shape and all the revisions between them in flat array? I'm not sure if this rewrite would be faster than safeJsonStringify, but I would think so.

Related

#8021 #8396

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions