From 4fd55f099be71d5b08631b2f79b462f20476403e Mon Sep 17 00:00:00 2001 From: Heikki Aitakangas Date: Sun, 13 Feb 2022 21:53:23 +0200 Subject: [PATCH] This should not reject with ScriptDeath, the script is not being killed. Just 'undefined' isn't great either so left a TODO about improving it --- src/NetscriptEvaluator.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/NetscriptEvaluator.ts b/src/NetscriptEvaluator.ts index 55501eb67..4ef8c6a22 100644 --- a/src/NetscriptEvaluator.ts +++ b/src/NetscriptEvaluator.ts @@ -4,8 +4,10 @@ import { ScriptDeath } from "./Netscript/ScriptDeath"; import { WorkerScript } from "./Netscript/WorkerScript"; export function netscriptDelay(time: number, workerScript: WorkerScript): Promise { - if (workerScript.delayReject) - workerScript.delayReject(new ScriptDeath(workerScript)); + // Cancel any pre-existing netscriptDelay'ed function call + // TODO: the rejection almost certainly ends up in the uncaught rejection handler. + // Maybe reject with a stack-trace'd error message? + if (workerScript.delayReject) workerScript.delayReject(); return new Promise(function (resolve, reject) { workerScript.delay = window.setTimeout(() => {