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
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
idbadapter also doesRewrite 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