From 94cf673f68cd24c0f03918ae7c50fb29536b7195 Mon Sep 17 00:00:00 2001 From: tophf Date: Sat, 6 Feb 2021 19:08:35 +0300 Subject: [PATCH] load semver faster, fixes #1167 --- background/update-manager.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/background/update-manager.js b/background/update-manager.js index d0ff6027..05f48486 100644 --- a/background/update-manager.js +++ b/background/update-manager.js @@ -213,8 +213,13 @@ const updateMan = (() => { } // TODO: when sourceCode is > 100kB use http range request(s) for version check const {headers: {etag}, response} = await tryDownload(style.updateUrl, RH_ETAG); - const json = await API.usercss.buildMeta({sourceCode: response, etag}); - await require(['/vendor/semver-bundle/semver']); /* global semverCompare */ + /* There's a bug? in Chrome which occurs only in a packaged crx: + * DOM script for semver fires 'load' event before the script actually runs. + * Since the conditions for the bug are rare we'll simply load in parallel */ + const [json] = await Promise.all([ + API.usercss.buildMeta({sourceCode: response, etag}), + require(['/vendor/semver-bundle/semver']), /* global semverCompare */ + ]); const delta = semverCompare(json.usercssData.version, ucd.version); let err; if (!delta && !ignoreDigest) {