Closed jmbreuer closed 3 months ago
The problem is in your hack-host.js
.
When you install augmentations or do a "soft reset", all running scripts are put in a "dead state" (this is a simplified explanation, the technical details are more complicated). If a script tries to use an NS API while it's in the "dead state", the NS function will throw an exception. In your hack-host.js
, when the exception is thrown, it's caught by the outer try catch
, then the script loops again immediately. It creates an infinite loop. That's why the game is frozen.
Generally, you should:
catch
part of the try catch
.await ns.sleep(a-number-value)
in the while (true)
as a safety handle./** @param {NS} ns */
export async function main(ns) {
while (true) {
try {
// Do something
ns.print(Date.now());
} catch (exception) {
ns.print(exception);
}
await ns.sleep(1000);
}
}
Aah, that is good to know!
Thank you.
At first, I was a bit at a loss since even the UI would not be able to kill some of the offending scripts, and the "Reload game / [x] kill all scripts" dialog of the Steam version wouldn't work for me - I wind up at a completely black empty page.
But, I found that I can overwrite the offending scripts on hosts where they're not killable with a better/fixed version and reload the game/page, which causes those fixed versions to run. From there, I could clean them up and successfully advance through my next round of Augmentations.
With the attached save (how I arrived there, see below under "Steps to reproduce", the game hangs and my computer's fans spin up - the game (tab) is consuming 100% CPU as soon as I click "Confirm" in the "Install Augmentations" dialog. I waited for a fair while (~ 10 minutes), the game does not recover from this.
I have not found a way to continue playing from this save yet, or by arriving in a comparable situation by loading an earlier save and spending the offline money on Augmentations.
include (where relevant)