Always store the error message and better error queue handling (#3522)

This commit is contained in:
Peter Hedenskog 2021-12-08 10:40:22 +01:00 committed by GitHub
parent 8508f7e67a
commit 05647d52c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -14,9 +14,6 @@ async function run(options) {
process.exitCode = 1;
try {
const result = await sitespeed.run(options);
if (result.errors.length > 0) {
throw new Error('Errors while running:\n' + result.errors.join('\n'));
}
if (options.storeResult) {
if (options.storeResult != 'true') {
@ -26,6 +23,10 @@ async function run(options) {
}
}
if (result.errors.length > 0) {
throw new Error('Errors while running:\n' + result.errors.join('\n'));
}
if ((options.open || options.o) && os.platform() === 'darwin') {
execSync('open ' + result.localPath + '/index.html');
}

View File

@ -125,10 +125,6 @@ class QueueHandler {
// FIXME handle rejections (i.e. failures while processing messages) properly
queue.processingEnded(obj => {
const message = obj.item;
// if we get a error message on the queue make sure we register that
if (message.type === 'error' || message.type.endsWith('.error')) {
this.errors.push(message.data);
}
const err = obj.err;
if (err) {
let rejectionMessage =
@ -197,6 +193,11 @@ class QueueHandler {
postMessage(message) {
validateMessageFormat(message);
// if we get a error message on the queue make sure we register that
if (message.type === 'error' || message.type.endsWith('.error')) {
this.errors.push('' + message.data);
}
// Don't return promise in loop - we don't want to wait for completion,
// just post the message.
for (let item of this.queues) {