mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 17:43:48 +01:00
NETSCRIPT: Revert infinite loop detection (#404)
This commit is contained in:
parent
59389b164a
commit
ea8ee743cc
@ -33,7 +33,6 @@ import { BaseServer } from "../Server/BaseServer";
|
|||||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||||
import { checkEnum } from "../utils/helpers/enum";
|
import { checkEnum } from "../utils/helpers/enum";
|
||||||
import { RamCostConstants } from "./RamCostGenerator";
|
import { RamCostConstants } from "./RamCostGenerator";
|
||||||
import { Settings } from "../Settings/Settings";
|
|
||||||
|
|
||||||
export const helpers = {
|
export const helpers = {
|
||||||
string,
|
string,
|
||||||
@ -304,15 +303,6 @@ function checkSingularityAccess(ctx: NetscriptContext): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The last time the page was able to update this tracking variable, which is used for timeout detection */
|
|
||||||
let lastTime = Date.now();
|
|
||||||
setInterval(() => (lastTime = Date.now()), 1000);
|
|
||||||
// This event should prevent false positive timeout errors when user alt-tabs / otherwise hides the window
|
|
||||||
document.addEventListener(
|
|
||||||
"visibilitychange",
|
|
||||||
() => (lastTime = document.visibilityState === "hidden" ? Infinity : Date.now()),
|
|
||||||
);
|
|
||||||
|
|
||||||
/** Create an error if a script is dead or if concurrent ns function calls are made */
|
/** Create an error if a script is dead or if concurrent ns function calls are made */
|
||||||
function checkEnvFlags(ctx: NetscriptContext): void {
|
function checkEnvFlags(ctx: NetscriptContext): void {
|
||||||
const ws = ctx.workerScript;
|
const ws = ctx.workerScript;
|
||||||
@ -333,17 +323,6 @@ function checkEnvFlags(ctx: NetscriptContext): void {
|
|||||||
"CONCURRENCY",
|
"CONCURRENCY",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// 8s allows scripts at least 7s of synchronous execution time before error, since updates are every 1s.
|
|
||||||
if (Settings.infiniteLoopDetection && Date.now() - 8000 > lastTime) {
|
|
||||||
// Prevent error getting piggybacked to another script due to a stale timer.
|
|
||||||
lastTime = Date.now();
|
|
||||||
|
|
||||||
throw makeRuntimeErrorMsg(
|
|
||||||
ctx,
|
|
||||||
"Possible infinite loop detected while running function.\nThis error is enabled by Options -> System -> Infinite loop detection.",
|
|
||||||
"EXECUTION TIMEOUT",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set a timeout for performing a task, mark the script as busy in the meantime. */
|
/** Set a timeout for performing a task, mark the script as busy in the meantime. */
|
||||||
|
@ -102,8 +102,6 @@ export const Settings = {
|
|||||||
useEngineeringNotation: false,
|
useEngineeringNotation: false,
|
||||||
/** Whether to disable suffixes and always use exponential form (scientific or engineering). */
|
/** Whether to disable suffixes and always use exponential form (scientific or engineering). */
|
||||||
disableSuffixes: false,
|
disableSuffixes: false,
|
||||||
/** Whether to check for execution timeout errors */
|
|
||||||
infiniteLoopDetection: true,
|
|
||||||
|
|
||||||
load(saveString: string) {
|
load(saveString: string) {
|
||||||
const save = JSON.parse(saveString);
|
const save = JSON.parse(saveString);
|
||||||
|
Loading…
Reference in New Issue
Block a user