From ccd9118b93663c0c351b43a0e2d81ca174f15990 Mon Sep 17 00:00:00 2001 From: Caldwell <115591472+Caldwell-74@users.noreply.github.com> Date: Tue, 8 Oct 2024 07:57:35 +0200 Subject: [PATCH] MISC: add stopFlag check before running main (#1689) It's possible that before the script starts runn, the stopFlag is set. --- src/NetscriptWorker.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/NetscriptWorker.ts b/src/NetscriptWorker.ts index b11a2896c..ba98c13ec 100644 --- a/src/NetscriptWorker.ts +++ b/src/NetscriptWorker.ts @@ -56,6 +56,9 @@ async function startNetscript2Script(workerScript: WorkerScript): Promise const loadedModule = await compile(script, scripts); + // if for whatever reason the stopFlag is already set we abort + if (workerScript.env.stopFlag) return; + if (!loadedModule) throw `${script.filename} cannot be run because the script module won't load`; const mainFunc = loadedModule.main; // TODO unplanned: Better error for "unexpected reserved word" when using await in non-async function?