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

report bug : data still there despite remove and destroy calls #3788

Closed
wants to merge 5 commits into from

Conversation

mmouterde
Copy link
Contributor

  • A BUGFIX

data still there despite remove and destroy calls

@pubkey
Copy link
Owner

pubkey commented May 5, 2022

destroy destroys the javascript object, it will not remove the data. I know that this is a bad naming, maybe we should change that in the future.

remove however should really remove the data.

Both, remove and destroy assume that the collection/database is no longer used. Your second query after the remove will likely return data from the query cache, so it makes you think that the data is still there.
We could add a check to every function call to check if the db/collection is already destroyed, but this would add to much overhead I think.

@mmouterde
Copy link
Contributor Author

Ok thanks for these precisions.

So my test can not be probant this way.

As mentionned on Gitter, my initial trouble comes from my indexedDB that still has documents once db.remove() and db.destroy() and col.remove() and `col.destroy() have been called.

pubkey added a commit that referenced this pull request May 7, 2022
@pubkey
Copy link
Owner

pubkey commented May 8, 2022

I tried to reproduce the problem with this test, but it didn't have any error.

/**
                 * @link https://github.com/pubkey/rxdb/pull/3788
                 */
                it('#3788 removing the collection should also remove all changes', async () => {
                    if (!config.storage.hasMultiInstance) {
                        return;
                    }

                    const dbName = randomCouchString();

                    const createDb = async () => {
                        const db = await createRxDatabase({
                            name: dbName,
                            storage: config.storage.getStorage(),
                            ignoreDuplicate: true
                        });
                        await db.addCollections({
                            human: { schema: schemas.human }
                        });
                        return db;
                    }

                    const db1 = await createDb();
                    await db1.collections.human.insert(schemaObjects.simpleHuman());
                    const db2 = await createDb();

                    // remove the collection on one database
                    await db1.human.remove();


                    /**
                     * Getting the changes in the other database should have an empty result.
                     */
                    const changesResult = await db2.human.storageInstance.getChangedDocumentsSince(10);

                    console.dir(changesResult);

                    assert.strictEqual(changesResult.length, 0);

                    db1.destroy();
                    db2.destroy();
                });

@mmouterde
Copy link
Contributor Author

@pubkey
Copy link
Owner

pubkey commented May 9, 2022

Closing this PR. Fixed in ca6ea15

@pubkey pubkey closed this May 9, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants