From 71dde4521c1801837bd96da02739ab690771c3cc Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Sun, 1 Nov 2020 20:37:26 +0000 Subject: [PATCH] Bug 1674418 - Properly handle conn.close() exception to not block async shutdown. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D95326 --- toolkit/components/places/PlacesUtils.jsm | 16 ++++++++++------ toolkit/modules/Sqlite.jsm | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/toolkit/components/places/PlacesUtils.jsm b/toolkit/components/places/PlacesUtils.jsm index 62f95f4a2a8e..79db19a06e59 100644 --- a/toolkit/components/places/PlacesUtils.jsm +++ b/toolkit/components/places/PlacesUtils.jsm @@ -2018,10 +2018,14 @@ function setupDbForShutdown(conn, name) { // At this stage, all external clients have finished using the // database. We just need to close the high-level connection. - await conn.close(); - state = "2. Closed Sqlite.jsm connection."; - - resolve(); + try { + await conn.close(); + state = "2. Closed Sqlite.jsm connection."; + resolve(); + } catch (ex) { + state = "2. Failed to closed Sqlite.jsm connection: " + ex; + reject(ex); + } }, () => state ); @@ -2030,13 +2034,13 @@ function setupDbForShutdown(conn, name) { conn.close(); reject(ex); } - }); + }).catch(Cu.reportError); // Make sure that Sqlite.jsm doesn't close until we are done // with the high-level connection. Sqlite.shutdown.addBlocker( `${name} must be closed before Sqlite.jsm`, - () => promiseClosed.catch(Cu.reportError), + () => promiseClosed, () => state ); } catch (ex) { diff --git a/toolkit/modules/Sqlite.jsm b/toolkit/modules/Sqlite.jsm index f86465eaf647..1ac5e23151aa 100644 --- a/toolkit/modules/Sqlite.jsm +++ b/toolkit/modules/Sqlite.jsm @@ -1190,6 +1190,7 @@ function cloneStorageConnection(options) { if (!connection) { log.warn("Could not clone connection: " + status); reject(new Error("Could not clone connection: " + status)); + return; } log.info("Connection cloned"); try {