mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 17:43:48 +01:00
fix some stack traces not printing file name
This commit is contained in:
parent
4460bf1613
commit
e117548895
@ -1,6 +1,7 @@
|
|||||||
import { isString } from "./utils/helpers/isString";
|
import { isString } from "./utils/helpers/isString";
|
||||||
import { GetServer } from "./Server/AllServers";
|
import { GetServer } from "./Server/AllServers";
|
||||||
import { WorkerScript } from "./Netscript/WorkerScript";
|
import { WorkerScript } from "./Netscript/WorkerScript";
|
||||||
|
import { BlobsMap } from "./NetscriptJSEvaluator";
|
||||||
|
|
||||||
export function netscriptDelay(time: number, workerScript: WorkerScript): Promise<void> {
|
export function netscriptDelay(time: number, workerScript: WorkerScript): Promise<void> {
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
@ -18,6 +19,11 @@ export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): s
|
|||||||
throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.hostname}`);
|
throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.hostname}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const url in BlobsMap) {
|
||||||
|
console.log(url);
|
||||||
|
// msg = msg.replace(new RegExp(url, "g"), BlobsMap[url]);
|
||||||
|
}
|
||||||
|
|
||||||
return "|DELIMITER|" + server.hostname + "|DELIMITER|" + workerScript.name + "|DELIMITER|" + msg;
|
return "|DELIMITER|" + server.hostname + "|DELIMITER|" + workerScript.name + "|DELIMITER|" + msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ import { ScriptUrl } from "./Script/ScriptUrl";
|
|||||||
import { WorkerScript } from "./Netscript/WorkerScript";
|
import { WorkerScript } from "./Netscript/WorkerScript";
|
||||||
import { Script } from "./Script/Script";
|
import { Script } from "./Script/Script";
|
||||||
|
|
||||||
|
export const BlobsMap: { [key: string]: string } = {};
|
||||||
|
|
||||||
// Makes a blob that contains the code of a given script.
|
// Makes a blob that contains the code of a given script.
|
||||||
function makeScriptBlob(code: string): Blob {
|
function makeScriptBlob(code: string): Blob {
|
||||||
return new Blob([code], { type: "text/javascript" });
|
return new Blob([code], { type: "text/javascript" });
|
||||||
@ -19,7 +21,10 @@ export async function compile(script: Script, scripts: Script[]): Promise<void>
|
|||||||
// by placing it inside an eval call.
|
// by placing it inside an eval call.
|
||||||
await script.updateRamUsage(scripts);
|
await script.updateRamUsage(scripts);
|
||||||
const uurls = _getScriptUrls(script, scripts, []);
|
const uurls = _getScriptUrls(script, scripts, []);
|
||||||
if (script.url) URL.revokeObjectURL(script.url); // remove the old reference.
|
if (script.url) {
|
||||||
|
URL.revokeObjectURL(script.url); // remove the old reference.
|
||||||
|
delete BlobsMap[script.url];
|
||||||
|
}
|
||||||
if (script.dependencies.length > 0) script.dependencies.forEach((dep) => URL.revokeObjectURL(dep.url));
|
if (script.dependencies.length > 0) script.dependencies.forEach((dep) => URL.revokeObjectURL(dep.url));
|
||||||
script.url = uurls[uurls.length - 1].url;
|
script.url = uurls[uurls.length - 1].url;
|
||||||
script.module = new Promise((resolve) => resolve(eval("import(uurls[uurls.length - 1].url)")));
|
script.module = new Promise((resolve) => resolve(eval("import(uurls[uurls.length - 1].url)")));
|
||||||
@ -133,7 +138,9 @@ function _getScriptUrls(script: Script, scripts: Script[], seen: Script[]): Scri
|
|||||||
|
|
||||||
// If we successfully transformed the code, create a blob url for it and
|
// If we successfully transformed the code, create a blob url for it and
|
||||||
// push that URL onto the top of the stack.
|
// push that URL onto the top of the stack.
|
||||||
urlStack.push(new ScriptUrl(script.filename, URL.createObjectURL(makeScriptBlob(transformedCode))));
|
const su = new ScriptUrl(script.filename, URL.createObjectURL(makeScriptBlob(transformedCode)));
|
||||||
|
urlStack.push(su);
|
||||||
|
BlobsMap[su.url] = su.filename;
|
||||||
return urlStack;
|
return urlStack;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// If there is an error, we need to clean up the URLs.
|
// If there is an error, we need to clean up the URLs.
|
||||||
|
Loading…
Reference in New Issue
Block a user