Skip to content

Commit

Permalink
fix: forward errors from WorkerThreads to consumers
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarpl committed Jul 21, 2022
1 parent cd379f1 commit 9a36299
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/parent-process/workerPlatform/webWorkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export class WebWorkerProcess extends WorkerPlatformBase {
} else console.log('unknown message type', message)
}
this.worker.onmessageerror = (error: any) => {
console.error('ww message error', error)
this.emit('error', error)
}
this.worker.onerror = (error: any) => {
console.error('ww error', error)
this.emit('error', error)
}
} catch (error) {
let str = (error.stack || error).toString() + ''
Expand Down
5 changes: 4 additions & 1 deletion src/parent-process/workerPlatform/workerThreads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ export class WorkerThread extends WorkerPlatformBase {
// if (message.type === 'message') {
// } else console.log('unknown message type', message)
})
this.worker.on('messageerror', (error: any) => {
this.emit('error', error)
})
this.worker.on('error', (error: any) => {
console.error('Worker Thread error', error)
this.emit('error', error)
})
this.worker.on('exit', (_code: number) => {
this.emit('close')
Expand Down

0 comments on commit 9a36299

Please sign in to comment.