From 64fc704527105afc8f06cafe8428e5c30c3ee097 Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Thu, 5 Aug 2021 06:49:41 +0000 Subject: [PATCH] [IMP] web: log module loading issues even when they throw a real error Previously, when an Error was thrown inside an async module, that error would not cause boot.js to log information about missing, failed or rejected modules. This is because we were only using guardedCatch to mark modules returning a rejected promise with something other than an error as rejected, but the case where a real error was thrown was not handled, which left the job to be forever pending. This commit fixes that by catching real errors after the previous processing, and treats it like an error in a synchronous module. --- addons/web/static/src/boot.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/boot.js b/addons/web/static/src/boot.js index d1165935c74..603811253f4 100644 --- a/addons/web/static/src/boot.js +++ b/addons/web/static/src/boot.js @@ -280,14 +280,16 @@ var require = makeRequire(job); var jobExec; + function onError(e) { + job.error = e; + console.error(`Error while loading ${job.name}: ${e.message}`, e); + } var def = new Promise(function (resolve) { try { jobExec = job.factory.call(null, require); jobs.splice(jobs.indexOf(job), 1); } catch (e) { - job.error = e; - console.error(e); - console.error(`Error while loading ${job.name}: ${e.message}`); + onError(e); } if (!job.error) { Promise.resolve(jobExec) @@ -299,6 +301,11 @@ .guardedCatch(function (e) { job.rejected = e || true; jobs.push(job); + }) + .catch(function (e) { + if (e instanceof Error) { + onError(e); + } resolve(); }); } else {