Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 08310e7

Browse files
committed
fix: null-check for workerInstance
1 parent b1bcd04 commit 08310e7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/workerHelper.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import cryptoRandomString from 'crypto-random-string';
44
import type * as Tslint from "tslint";
55

66
export class WorkerHelper {
7-
workerInstance: Task
7+
workerInstance: Task | null
88
constructor() {
99
this.workerInstance = null;
1010
}
@@ -37,13 +37,16 @@ export class WorkerHelper {
3737
}
3838

3939
async requestJob(jobType: string, textEditor: TextEditor): Promise<Tslint.LintResult[]> {
40-
if (!this.workerInstance) {
40+
if (this.workerInstance === null) {
4141
throw new Error("Worker hasn't started");
4242
}
4343

4444
const emitKey = await cryptoRandomString.async({ length: 10 });
4545

4646
return new Promise((resolve, reject) => {
47+
if (this.workerInstance === null) {
48+
throw new Error("Worker hasn't started");
49+
}
4750
const errSub = this.workerInstance.on('task:error', (...err) => {
4851
// Re-throw errors from the task
4952
const error = new Error(err[0]);

0 commit comments

Comments
 (0)