From dc80e503bb70a4152c4b0a08c868101c03cdc6f1 Mon Sep 17 00:00:00 2001 From: Ginger <75683114+gingershaped@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:08:52 -0400 Subject: [PATCH] Fix crash when restarting execution --- src/latest/scripts/interpreter/runner.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/latest/scripts/interpreter/runner.ts b/src/latest/scripts/interpreter/runner.ts index 14fd526..9733327 100644 --- a/src/latest/scripts/interpreter/runner.ts +++ b/src/latest/scripts/interpreter/runner.ts @@ -169,8 +169,8 @@ export class VyRunner extends TypedEventTarget { window.location.assign("https://www.youtube.com/watch?v=dQw4w9WgXcQ"); return; } - if (this._state != "idle") { - throw new Error("Attempted to start while not idle"); + if (this._state == "running") { + throw new Error("Attempted to start while running"); } await this.worker; this.terminal?.clear(); @@ -193,12 +193,12 @@ export class VyRunner extends TypedEventTarget { }); } - terminate(reason: TerminateReason = TerminateReason.Terminated) { + async terminate(reason: TerminateReason = TerminateReason.Terminated) { if (this._state != "running") { throw new Error("Attempted to terminate worker while not running"); } console.log("Terminating worker"); - this.worker.then((worker) => { + await this.worker.then((worker) => { this._state = "booting"; this.worker = this.spawnWorker(); worker.terminate();