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

Sync error after disconnect #939

Closed
skddc opened this Issue Jun 21, 2016 · 1 comment

Comments

2 participants
@skddc
Copy link
Member

skddc commented Jun 21, 2016

There seems to be some race condition where a sync task is still scheduled and executed after disconnecting storage, but the DB is not available anymore:

screenshot from 2016-06-21 18-35-56

It doesn't really break this app (and shouldn't break other apps). Only throws an exception after logout in some cases. We should delete all sync tasks during disconnect anyway.

@galfert

This comment has been minimized.

Copy link
Member

galfert commented Mar 14, 2018

I have seen this error again using the latest rs.js version (1.0.2).

It happened in the same integration test I described in #1117, after that issue with the undefined sync instance was fixed.

Looks to me like this happens when disconnecting the storage while it's still writing the results of the last sync call to IndexedDB here:

let transaction = this.db.transaction(['nodes'], 'readwrite');
let nodesStore = transaction.objectStore('nodes');
let startTime = new Date().getTime();
this.putsRunning++;
log('[IndexedDB] Starting put', nodes, this.putsRunning);
for (var path in nodes) {
var node = nodes[path];
if(typeof(node) === 'object') {
try {
nodesStore.put(node);
} catch(e) {
log('[IndexedDB] Error while putting', node, e);
throw e;
}
} else {
try {
nodesStore.delete(path);
} catch(e) {
log('[IndexedDB] Error while removing', nodesStore, node, e);
throw e;
}
}
}

What's weird is that I tried to wrap this whole code block in a try...catch and still couldn't catch this exception.

@galfert galfert reopened this Mar 14, 2018

@galfert galfert self-assigned this Mar 14, 2018

@galfert galfert added in progress and removed ready labels Mar 14, 2018

galfert added a commit that referenced this issue Mar 14, 2018

Don't close IndexedDB DB while still writing to it
Waits for the writes to finish first before closing the DB.

Fixes #939

@skddc skddc closed this in #1119 Mar 19, 2018

@skddc skddc removed the in progress label Mar 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment