MISC: Allow killing scripts during tutorial (#2797)

This commit is contained in:
catloversg
2026-05-22 07:57:06 +07:00
committed by GitHub
parent b8dc41faca
commit 0e39a5f603
2 changed files with 5 additions and 16 deletions
+1 -9
View File
@@ -8,20 +8,12 @@ import { workerScripts } from "./WorkerScripts";
import { GetAllServers, GetServer } from "../Server/AllServers";
import { AddRecentScript } from "./RecentScripts";
import { ITutorial } from "../InteractiveTutorial";
import { AlertEvents } from "../ui/React/AlertManager";
import { handleUnknownError } from "../utils/ErrorHandler";
import { roundToTwo } from "../utils/helpers/roundToTwo";
import { BaseServer } from "../Server/BaseServer";
export function killWorkerScript(ws: WorkerScript): boolean {
if (ITutorial.isRunning) {
AlertEvents.emit("Processes cannot be killed during the tutorial.");
return false;
}
export function killWorkerScript(ws: WorkerScript): void {
stopAndCleanUpWorkerScript(ws);
return true;
}
export function killWorkerScriptByPid(pid: number, killer?: WorkerScript): boolean {
+4 -7
View File
@@ -675,18 +675,15 @@ export const ns: InternalAPI<NSFull> = {
}
helpers.log(ctx, () => "About to exit...");
const killed = killWorkerScript(ctx.workerScript);
killWorkerScript(ctx.workerScript);
if (runOpts.spawnDelay === 0) {
helpers.log(ctx, () => `Executing '${path}' immediately`);
spawnCb();
}
if (killed) {
// This prevents error messages about statements after the spawn()
// trying to be executed when the script is dead.
throw new ScriptDeath(ctx.workerScript);
}
// This prevents error messages about statements after the spawn()
// trying to be executed when the script is dead.
throw new ScriptDeath(ctx.workerScript);
},
self: (ctx) => () => {
const runningScript = helpers.getRunningScript(ctx, ctx.workerScript.pid);