Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

refactor(browser): map artifact failures at one boundary

morluto5b0373db11ac
diff --git a/src/browser/assets/WebSourceLocationArtifacts.ts b/src/browser/assets/WebSourceLocationArtifacts.ts
index f15503d07..7be5133ac 100644
--- a/src/browser/assets/WebSourceLocationArtifacts.ts
+++ b/src/browser/assets/WebSourceLocationArtifacts.ts
@@ -60,39 +60,24 @@ export class LocalWebSourceLocationArtifacts implements WebSourceLocationArtifac
async #load(input: WebSourceLocationInput, options?: ExecutionOptions) {
const loaded = await this.scripts.load(input, options);
if (!loaded.ok) return loaded;
- try {
- const data = await readStableArtifact(
- input.source_map.path,
- WEB_SOURCE_MAP_LIMITS.mapBytes,
- options?.signal,
- undefined,
- this.#resources,
- );
- return ok({
- ...loaded.value,
- sourceMap: {
- file: {
- path: input.source_map.path,
- sha256: data.sha256,
- bytes: data.bytes.length,
- },
- url: input.source_map.url,
- text: decodeWebArtifact(data.bytes),
+ const data = await readStableArtifact(
+ input.source_map.path,
+ WEB_SOURCE_MAP_LIMITS.mapBytes,
+ options?.signal,
+ undefined,
+ this.#resources,
+ );
+ return ok({
+ ...loaded.value,
+ sourceMap: {
+ file: {
+ path: input.source_map.path,
+ sha256: data.sha256,
+ bytes: data.bytes.length,
},
- });
- } catch (cause: unknown) {
- return err(
- webArtifactReadError(
- cause,
- {
- operation: "trace_web_source_location",
- field: ["source_map", "path"],
- targetPath: input.source_map.path,
- callerSelected: true,
- },
- options?.signal,
- ),
- );
- }
+ url: input.source_map.url,
+ text: decodeWebArtifact(data.bytes),
+ },
+ });
}
}
diff --git a/src/browser/modules/WebModuleArtifacts.ts b/src/browser/modules/WebModuleArtifacts.ts
index 9c9b72e90..3f9ee086d 100644
--- a/src/browser/modules/WebModuleArtifacts.ts
+++ b/src/browser/modules/WebModuleArtifacts.ts
@@ -69,36 +69,21 @@ export class LocalWebModuleArtifacts implements WebModuleArtifactPort {
if (input.import_map === undefined)
return ok({ ...loaded.value, importMap: null });
const selected = input.import_map;
- try {
- const data = await readWebArtifactJson(
- selected.path,
- 4 * 1024 * 1024,
- options?.signal,
- this.#resources,
- );
- const importMap: WebModuleArtifacts["importMap"] = {
- file: {
- path: selected.path,
- sha256: data.sha256,
- bytes: data.bytes.length,
- },
- baseUrl: selected.base_url,
- value: jsonObjectSchema.parse(data.value),
- };
- return ok({ ...loaded.value, importMap });
- } catch (cause: unknown) {
- return err(
- webArtifactReadError(
- cause,
- {
- operation: "trace_web_module_imports",
- field: ["import_map", "path"],
- targetPath: selected.path,
- callerSelected: true,
- },
- options?.signal,
- ),
- );
- }
+ const data = await readWebArtifactJson(
+ selected.path,
+ 4 * 1024 * 1024,
+ options?.signal,
+ this.#resources,
+ );
+ const importMap: WebModuleArtifacts["importMap"] = {
+ file: {
+ path: selected.path,
+ sha256: data.sha256,
+ bytes: data.bytes.length,
+ },
+ baseUrl: selected.base_url,
+ value: jsonObjectSchema.parse(data.value),
+ };
+ return ok({ ...loaded.value, importMap });
}
}