diff --git a/src/NetscriptWorker.ts b/src/NetscriptWorker.ts index 471aa75b3..ade09fa8c 100644 --- a/src/NetscriptWorker.ts +++ b/src/NetscriptWorker.ts @@ -119,7 +119,13 @@ function startNetscript2Script(workerScript: WorkerScript): Promise { + return new Promise((resolve, reject) => { + executeJSScript(workerScript.getServer().scripts, workerScript) + .then(() => { + resolve(workerScript); + }) + .catch((e) => reject(e)); + }).catch((e) => { if (e instanceof Error) { workerScript.errorMessage = makeRuntimeRejectMsg( workerScript, @@ -518,7 +524,7 @@ export function createAndAddWorkerScript( // Once the code finishes (either resolved or rejected, doesnt matter), set its // running status to false - p.then(function (w) { + p.then(function (w: WorkerScript) { // On natural death, the earnings are transfered to the parent if it still exists. if (parent !== undefined) { if (parent.running) { diff --git a/src/Terminal/Terminal.ts b/src/Terminal/Terminal.ts index 967fe72ce..789c3b4e6 100644 --- a/src/Terminal/Terminal.ts +++ b/src/Terminal/Terminal.ts @@ -92,7 +92,7 @@ export class Terminal implements ITerminal { append(item: Output | Link): void { this.outputHistory.push(item); if (this.outputHistory.length > Settings.MaxTerminalCapacity) { - this.outputHistory.slice(this.outputHistory.length - Settings.MaxTerminalCapacity); + this.outputHistory.splice(0, this.outputHistory.length - Settings.MaxTerminalCapacity); } TerminalEvents.emit(); } diff --git a/src/Terminal/ui/TerminalRoot.tsx b/src/Terminal/ui/TerminalRoot.tsx index 0e3b29767..7ae50428d 100644 --- a/src/Terminal/ui/TerminalRoot.tsx +++ b/src/Terminal/ui/TerminalRoot.tsx @@ -61,8 +61,8 @@ export function TerminalRoot({ terminal, router, player }: IProps): React.ReactE setKey((key) => key + 1); } - useEffect(() => TerminalEvents.subscribe(_.debounce(rerender, 25, { maxWait: 50 })), []); - useEffect(() => TerminalClearEvents.subscribe(_.debounce(clear, 25, { maxWait: 50 })), []); + useEffect(() => TerminalEvents.subscribe(rerender), []); + useEffect(() => TerminalClearEvents.subscribe(clear), []); function doScroll(): void { const hook = scrollHook.current;