marceljuenemann / rxdb-supabase

Offline support for Supabase using RxDB
MIT License
133 stars 4 forks source link

Error: ensureNotFalsy() is falsy in getSingleDocument #15

Open szsolutions opened 5 months ago

szsolutions commented 5 months ago

Hi

I try to run the example according to the description, but I get an error when creating the replication: ensureNotFalsy() is falsy

The error occurs with the addConnectedStorageToCollection function, namely with getSingleDocument, which returns zero

async function addConnectedStorageToCollection(collection, storageCollectionName, schema) {
  var collectionNameWithVersion = _collectionNamePrimary(collection.name, collection.schema.jsonSchema);
  var collectionDocId = getPrimaryKeyOfInternalDocument(collectionNameWithVersion, INTERNAL_CONTEXT_COLLECTION);
  while (true) {
=>>>    var collectionDoc = await getSingleDocument(collection.database.internalStore, collectionDocId);
=>>>    var saveData = clone(ensureNotFalsy(collectionDoc));
    if (!saveData.data.connectedStorages) {
      saveData.data.connectedStorages = [];
    }
    var alreadyThere = saveData.data.connectedStorages.find((row) => row.collectionName === storageCollectionName && row.schema.version === schema.version);
    if (alreadyThere) {
      return;
    }

This rxdb function has apparently changed, but since version 14.15.1 is used in the project, the changes are not included.

https://github.com/pubkey/rxdb/commit/46f36368b58a9484f00145b85e61e4af21a85f06#diff-96872ef558a49d727431d58ca95d9fc2791e8b1727edfca0fcfdabac159b79c3R52

i just don't understand why this could have worked before? maybe i'm completely wrong

marceljuenemann commented 5 months ago

Could you include the code that you're trying to run? Even better of course would be a minimal failing test case :)

Are you saying it's a bug in RxDB? Does the problem go away if you set an explicit RxDB version in your package.json?

szsolutions commented 5 months ago

Thank you very much for your advice. It was really due to the different versions. if I use the rxdb version 14.15.1 in packing.json, it works!

marceljuenemann commented 5 months ago

Are you sure you mean 14.15.1? Because that's the one in the package.json of this project already. If there is a bug that was fixed in a later version, I should probably bump versions and do another release

nukeop commented 3 months ago

Is it possible for you to release a version compatible with rxdb@15? There is a feature in 15 that I'd like to use, together with rxdb-supabase.

mbeckenbach commented 2 months ago

I can confirm that downgrading to rxdb 14.15.1 works. Supporting v15 would be nice anyway.