Skip to content

Commit bf9a265

Browse files
committed
fix(wasm): Avoid throwing an error when WASM modules are loaded from blobs
1 parent 8482c0a commit bf9a265

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/wasm/src/registry.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,22 @@ export function registerModule(module: WebAssembly.Module, url: string): void {
4545
if (oldIdx >= 0) {
4646
IMAGES.splice(oldIdx, 1);
4747
}
48+
49+
let debugFileUrl = null;
50+
if (debugFile) {
51+
try {
52+
debugFileUrl = new URL(debugFile, url).href;
53+
} catch {
54+
// debugFile could be a blob URL which causes the URL constructor to throw
55+
// for now we just ignore this case
56+
}
57+
}
58+
4859
IMAGES.push({
4960
type: 'wasm',
5061
code_id: buildId,
5162
code_file: url,
52-
debug_file: debugFile ? new URL(debugFile, url).href : null,
63+
debug_file: debugFileUrl,
5364
debug_id: `${buildId.padEnd(32, '0').slice(0, 32)}0`,
5465
});
5566
}

0 commit comments

Comments
 (0)