Skip to content

Commit

Permalink
Fix crash when restarting execution
Browse files Browse the repository at this point in the history
  • Loading branch information
gingershaped committed Oct 30, 2024
1 parent 76ce1c6 commit dc80e50
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/latest/scripts/interpreter/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ export class VyRunner extends TypedEventTarget<VyRunnerEvents> {
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();
Expand All @@ -193,12 +193,12 @@ export class VyRunner extends TypedEventTarget<VyRunnerEvents> {
});
}

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();
Expand Down

0 comments on commit dc80e50

Please sign in to comment.