mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 11:06:06 -04:00
Try to fix 'The database connection is closing' issues
Browsers may rarely randomly close the IndexedDB connection, which would prevent the game from being able to save options or maps anymore until the user restarted the game. With this commit, the game now listens for the 'onclose' event on the IDBConnection for when the connection is unexpectedly closed - and when the 'onclose' event is raised, clears the cached IndexedDB connection global so that the next call to getDB opens a fresh IndexedDB connection. I tested this by deleting the IndexedDB database in developer tools (which triggered 'onclose' event) and seemed to work fine
This commit is contained in:
parent
8b986b5ccd
commit
87bcdd1e43
@ -368,6 +368,11 @@ mergeInto(LibraryManager.library, {
|
||||
req.onsuccess = function() {
|
||||
db = req.result;
|
||||
window.IDBFS_db = db;
|
||||
// browser will sometimes close connection behind the scenes
|
||||
db.onclose = function(ev) {
|
||||
console.log('IndexedDB connection closed unexpectedly!');
|
||||
window.IDBFS_db = null;
|
||||
}
|
||||
callback(null, db);
|
||||
};
|
||||
req.onerror = function(e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user