I’m working on adding conflict detection during sync and I’m encountering a strange inconsistent bug. Sometimes the sync and subsequent scan for conflicts succeeds, sometimes I get errors like this:
TypeError: Cannot set properties of undefined (setting 'id')
at fromRawDoc (webpack://__ember_auto_import__/./node_modules/.pnpm/relational-pouch@4.0.4_pouchdb-find@8.0.1/node_modules/relational-pouch/lib/index.js?:24:66)
at _parseRelDocs (webpack://__ember_auto_import__/./node_modules/.pnpm/relational-pouch@4.0.4_pouchdb-find@8.0.1/node_modules/relational-pouch/lib/index.js?:29:720)
at _parseAlldocs (webpack://__ember_auto_import__/./node_modules/.pnpm/relational-pouch@4.0.4_pouchdb-find@8.0.1/node_modules/relational-pouch/lib/index.js?:29:281)
at _find (webpack://__ember_auto_import__/./node_modules/.pnpm/relational-pouch@4.0.4_pouchdb-find@8.0.1/node_modules/relational-pouch/lib/index.js?:28:94)
at async Class._findRecord (http://localhost:4190/assets/vendor.js:91649:21)
Looking at the function in question, frowRawDoc, the problem is that pouchDoc.data is sometimes undefined, like this:
{
"name": "A region version 100",
"_id": "region_2_778B4E9D-8C63-7D27-B28E-CBA85B8F8F97",
"_rev": "2-a526bf91fa35aaceedf48f58dca458ad"
}
When the error doesn’t happen (most of the time) pouchDoc is the expected structure:
The code for finding conflicts is here, it uses allDocs (with include_docs) but you can see in the commented-out code that I tried watching changes too, which actually seemed to produce more errors. Is this how people are working with conflicts, is there any way we can make them first-class with Ember Pouch models?
The actual failures are happening in relational-pouch but I’m not sure which library is actually at fault.
I’m working on adding conflict detection during sync and I’m encountering a strange inconsistent bug. Sometimes the sync and subsequent scan for conflicts succeeds, sometimes I get errors like this:
Looking at the function in question,
frowRawDoc
, the problem is thatpouchDoc.data
is sometimes undefined, like this:When the error doesn’t happen (most of the time)
pouchDoc
is the expected structure:The code for finding conflicts is here, it uses
allDocs
(withinclude_docs
) but you can see in the commented-out code that I tried watchingchanges
too, which actually seemed to produce more errors. Is this how people are working with conflicts, is there any way we can make them first-class with Ember Pouch models?The actual failures are happening in
relational-pouch
but I’m not sure which library is actually at fault.