remotestorage / remotestorage.js

⬡ JavaScript client library for integrating remoteStorage in apps
https://remotestoragejs.readthedocs.io
MIT License
2.31k stars 141 forks source link

client.remove() produces non-existing node errors #1255

Open bdashore3 opened 2 years ago

bdashore3 commented 2 years ago

Environment:

Hi there, I'm currently working with managing files in remoteStorage where adding and reading files works fine. However, using the remove function produces this error and doesn't delete the file:

Cannot delete non-existing node /test-project/index.html
Cannot delete non-existing node /test-project/
Cannot delete non-existing node /

Code:


const remoteStorage = new RemoteStorage();
remoteStorage.access.claim('*', 'rw');

remoteStorage.connect('user@5apps.com', 'token');

remoteStorage.on('ready', () => {
    console.log('remotestorage is ready');
});
remoteStorage.on('connected', () => {
    const userAddress = remoteStorage.remote.userAddress;
    console.debug(`${userAddress} connected their remote storage.`);
    const client = remoteStorage.scope('/test-project/');

    client
        .remove('index.html')
        .then((x) => console.log(x))
        .catch((err) => console.log(err));
});
raucao commented 2 years ago

Before investigating this, just a note:

This could be an edge case with the default caching strategy (caching is enabled with the SEEN strategy by default) and node.js usage, which uses in-memory caching and where the cache is lost between restarts.

See https://remotestoragejs.readthedocs.io/en/latest/js-api/caching.html for details about caching.

However, it is still a bug, of course, because it should fetch metadata of the remote document again in this case, and delete it upon seeing it's there, before claiming that the document does not exist at all.

raucao commented 1 year ago

@bdashore3 Is this still a problem for you? If so, could you provide a more complete version of the failing code, so we can reproduce the error?