From 529e3fb39a47c24c0e1550a0b11dfbf6f72cab45 Mon Sep 17 00:00:00 2001 From: James Aguilar <799564+jaguilar@users.noreply.github.com> Date: Tue, 8 May 2018 21:40:07 -0400 Subject: [PATCH] Can't return promise sleep, nobody is awaiting it! --- src/NetscriptWorker.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/NetscriptWorker.js b/src/NetscriptWorker.js index 0b5aa2a81..0fc043d26 100644 --- a/src/NetscriptWorker.js +++ b/src/NetscriptWorker.js @@ -78,7 +78,9 @@ function startJsScript(workerScript) { // netscript functions that don't check this. // This is not a problem for legacy Netscript because it also checks the // stop flag in the evaluator. - if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} + if (workerScript.env.stopFlag) {throw workerScript;} + + if (propName === "sleep") return f(...args); // OK for multiple simultaneous calls to sleep. const msg = "Concurrent calls to Netscript functions not allowed! " + "Did you forget to await hack(), grow(), or some other " + @@ -99,9 +101,9 @@ function startJsScript(workerScript) { } } }; + for (let prop in workerScript.env.vars) { if (typeof workerScript.env.vars[prop] !== "function") continue; - if (prop === "sleep") continue; // OK for multiple simultaneous calls to sleep. workerScript.env.vars[prop] = wrap(prop, workerScript.env.vars[prop]); }