diff --git a/src/vs/base/common/worker/workerClient.ts b/src/vs/base/common/worker/workerClient.ts index 61fef76290dc7..86a5676b3305d 100644 --- a/src/vs/base/common/worker/workerClient.ts +++ b/src/vs/base/common/worker/workerClient.ts @@ -227,7 +227,9 @@ export class WorkerClient { } private _postMessage(msg:any): void { - this._worker.postMessage(stringify(msg)); + if (this._worker) { + this._worker.postMessage(stringify(msg)); + } } private _onSerializedMessage(msg:string): void { diff --git a/src/vs/base/worker/defaultWorkerFactory.ts b/src/vs/base/worker/defaultWorkerFactory.ts index abfa5b9935c02..36dc060d5d2ef 100644 --- a/src/vs/base/worker/defaultWorkerFactory.ts +++ b/src/vs/base/worker/defaultWorkerFactory.ts @@ -41,7 +41,9 @@ class WebWorker implements IWorker { } public postMessage(msg:string): void { - this.worker.postMessage(msg); + if (this.worker) { + this.worker.postMessage(msg); + } } public dispose(): void {