mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-22 22:22:26 +01:00
More permanent fix for infinite sleeps.
This commit is contained in:
parent
7045f5d74e
commit
f259a5c17d
@ -229,7 +229,6 @@ function NetscriptFunctions(workerScript) {
|
|||||||
workerScript.scriptRef.log("Sleeping for " + time + " milliseconds");
|
workerScript.scriptRef.log("Sleeping for " + time + " milliseconds");
|
||||||
}
|
}
|
||||||
return netscriptDelay(time, workerScript).then(function() {
|
return netscriptDelay(time, workerScript).then(function() {
|
||||||
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
|
|
||||||
return Promise.resolve(true);
|
return Promise.resolve(true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -73,6 +73,13 @@ function startJsScript(workerScript) {
|
|||||||
// This function unfortunately cannot be an async function, because we don't
|
// This function unfortunately cannot be an async function, because we don't
|
||||||
// know if the original one was, and there's no way to tell.
|
// know if the original one was, and there's no way to tell.
|
||||||
return function (...args) {
|
return function (...args) {
|
||||||
|
// Wrap every netscript function with a check for the stop flag.
|
||||||
|
// This prevents cases where we never stop because we are only calling
|
||||||
|
// 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);}
|
||||||
|
|
||||||
const msg = "Concurrent calls to Netscript functions not allowed! " +
|
const msg = "Concurrent calls to Netscript functions not allowed! " +
|
||||||
"Did you forget to await hack(), grow(), or some other " +
|
"Did you forget to await hack(), grow(), or some other " +
|
||||||
"promise-returning function? (Currently running: %s tried to run: %s)"
|
"promise-returning function? (Currently running: %s tried to run: %s)"
|
||||||
|
Loading…
Reference in New Issue
Block a user