[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.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user