mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
fix scripts not dying
This commit is contained in:
parent
2a966d0726
commit
ec33fb411c
@ -119,7 +119,13 @@ function startNetscript2Script(workerScript: WorkerScript): Promise<WorkerScript
|
|||||||
|
|
||||||
// Note: the environment that we pass to the JS script only needs to contain the functions visible
|
// Note: the environment that we pass to the JS script only needs to contain the functions visible
|
||||||
// to that script, which env.vars does at this point.
|
// to that script, which env.vars does at this point.
|
||||||
return executeJSScript(workerScript.getServer().scripts, workerScript).catch((e) => {
|
return new Promise<WorkerScript>((resolve, reject) => {
|
||||||
|
executeJSScript(workerScript.getServer().scripts, workerScript)
|
||||||
|
.then(() => {
|
||||||
|
resolve(workerScript);
|
||||||
|
})
|
||||||
|
.catch((e) => reject(e));
|
||||||
|
}).catch((e) => {
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
workerScript.errorMessage = makeRuntimeRejectMsg(
|
workerScript.errorMessage = makeRuntimeRejectMsg(
|
||||||
workerScript,
|
workerScript,
|
||||||
@ -518,7 +524,7 @@ export function createAndAddWorkerScript(
|
|||||||
|
|
||||||
// Once the code finishes (either resolved or rejected, doesnt matter), set its
|
// Once the code finishes (either resolved or rejected, doesnt matter), set its
|
||||||
// running status to false
|
// 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.
|
// On natural death, the earnings are transfered to the parent if it still exists.
|
||||||
if (parent !== undefined) {
|
if (parent !== undefined) {
|
||||||
if (parent.running) {
|
if (parent.running) {
|
||||||
|
@ -92,7 +92,7 @@ export class Terminal implements ITerminal {
|
|||||||
append(item: Output | Link): void {
|
append(item: Output | Link): void {
|
||||||
this.outputHistory.push(item);
|
this.outputHistory.push(item);
|
||||||
if (this.outputHistory.length > Settings.MaxTerminalCapacity) {
|
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();
|
TerminalEvents.emit();
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,8 @@ export function TerminalRoot({ terminal, router, player }: IProps): React.ReactE
|
|||||||
setKey((key) => key + 1);
|
setKey((key) => key + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => TerminalEvents.subscribe(_.debounce(rerender, 25, { maxWait: 50 })), []);
|
useEffect(() => TerminalEvents.subscribe(rerender), []);
|
||||||
useEffect(() => TerminalClearEvents.subscribe(_.debounce(clear, 25, { maxWait: 50 })), []);
|
useEffect(() => TerminalClearEvents.subscribe(clear), []);
|
||||||
|
|
||||||
function doScroll(): void {
|
function doScroll(): void {
|
||||||
const hook = scrollHook.current;
|
const hook = scrollHook.current;
|
||||||
|
Loading…
Reference in New Issue
Block a user