Bug 1645331 - Catch asyncClose exceptions and mark the database as closed. r=lina
authorMarco Bonardo <mbonardo@mozilla.com>
Sat, 13 Jun 2020 03:10:45 +0000
changeset 535591 360d257d80c8bc5fbce3efc0f36af3b171be1744
parent 535590 ec174e49592bd1d552f83811076f60af20da5076
child 535592 51d94f5560cb6b7c0dd32b566cc18d00d0b4c790
push id118949
push userkcambridge@mozilla.com
push dateSat, 13 Jun 2020 03:11:39 +0000
treeherderautoland@360d257d80c8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslina
bugs1645331
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1645331 - Catch asyncClose exceptions and mark the database as closed. r=lina Differential Revision: https://phabricator.services.mozilla.com/D79447
toolkit/modules/Sqlite.jsm
--- a/toolkit/modules/Sqlite.jsm
+++ b/toolkit/modules/Sqlite.jsm
@@ -509,18 +509,25 @@ ConnectionData.prototype = Object.freeze
       this._deferredClose.resolve();
     };
     if (wrappedConnections.has(this._identifier)) {
       wrappedConnections.delete(this._identifier);
       this._dbConn = null;
       markAsClosed();
     } else {
       this._log.debug("Calling asyncClose().");
-      this._dbConn.asyncClose(markAsClosed);
-      this._dbConn = null;
+      try {
+        this._dbConn.asyncClose(markAsClosed);
+      } catch (ex) {
+        // If for any reason asyncClose fails, we must still remove the
+        // shutdown blockers and resolve _deferredClose.
+        markAsClosed();
+      } finally {
+        this._dbConn = null;
+      }
     }
     return this._deferredClose.promise;
   },
 
   executeCached(sql, params = null, onRow = null) {
     this.ensureOpen();
 
     if (!sql) {