Skip to content

Commit e88d68a

Browse files
committed
test
1 parent 1af80f5 commit e88d68a

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/utils/errorTraceHandler.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ export async function handleWebAssemblyError(
123123
Error.prepareStackTrace = originalPrepareStackTrace;
124124

125125
const wasmBuffer = await readFile(wasmPath);
126-
const sourceMapPath = parseSourceMapPath(wasmBuffer.buffer as ArrayBuffer);
126+
const sourceMapPath = parseSourceMapPath(
127+
wasmBuffer.buffer.slice(wasmBuffer.byteOffset, wasmBuffer.byteLength) as ArrayBuffer
128+
);
127129
const sourceMapConsumer: SourceMapHandler | null = await getSourceMapConsumer(sourceMapPath);
128130
const stacks = stackTrace
129131
.map((callSite) => createWebAssemblyCallSite(callSite, { wasmPath, sourceMapConsumer }))
88 Bytes
Binary file not shown.

tests/ts/test/utils/wasmparser.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { parseImportFunctionInfo } from "../../../../src/utils/wasmparser.js";
1+
import { parseImportFunctionInfo, parseSourceMapPath } from "../../../../src/utils/wasmparser.js";
22
import { readFileSync } from "node:fs";
33
import { join } from "node:path";
44
import { fileURLToPath, URL } from "node:url";
@@ -51,3 +51,12 @@ test("parseImportFunctionInfo", () => {
5151

5252
expect(parseImportFunctionInfo(arrayBuffer)).toEqual(expectedInfo); // Pass ArrayBuffer
5353
});
54+
55+
test("parseSourceMapURL", () => {
56+
const fp = join(__dirname, "..", "..", "fixture", "withSourceMapURL.wasm");
57+
const buf = readFileSync(fp);
58+
const arrayBuffer = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); // Convert Buffer to ArrayBuffer
59+
console.log(arrayBuffer);
60+
61+
expect(parseSourceMapPath(arrayBuffer)).toBe("./release.wasm.map");
62+
});

0 commit comments

Comments
 (0)