Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit d9d000a

Browse files
committed
fix(errors): better error msg reporting from worker threads
1 parent 7a0417d commit d9d000a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/util/helpers.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,15 @@ export function buildErrorToJson(buildError: BuildError) {
389389
};
390390
}
391391

392+
export function jsonToBuildError(nonTypedBuildError: any) {
393+
const error = new BuildError(new Error(nonTypedBuildError.message));
394+
error.name = nonTypedBuildError.name;
395+
error.stack = nonTypedBuildError.stack;
396+
error.hasBeenLogged = nonTypedBuildError.hasBeenLogged;
397+
error.isFatal = nonTypedBuildError.isFatal;
398+
return error;
399+
}
400+
392401
export function upperCaseFirst(input: string) {
393402
if (input.length > 1) {
394403
return input.charAt(0).toUpperCase() + input.substr(1);

src/worker-client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BuildContext, WorkerProcess, WorkerMessage } from './util/interfaces';
22
import { BuildError } from './util/errors';
3+
import { jsonToBuildError } from './util/helpers';
34
import { Logger } from './logger/logger';
45
import { fork, ChildProcess } from 'child_process';
56
import { join } from 'path';
@@ -37,7 +38,8 @@ export function runWorker(taskModule: string, taskWorker: string, context: Build
3738
reject(new BuildError(msg.error));
3839

3940
} else if (msg.reject) {
40-
reject(new BuildError(msg.reject));
41+
const buildError = jsonToBuildError(msg.reject);
42+
reject(buildError);
4143

4244
} else {
4345
resolve(msg.resolve);

0 commit comments

Comments
 (0)