Skip to content

Commit

Permalink
fix(wasm): Avoid throwing an error when WASM modules are loaded from …
Browse files Browse the repository at this point in the history
…blobs (#8263)

Try-catch the URL creation to avoid throwing an error if a funky URL is
encountered.

fixes #8259 

This will not fix symbolication for blob/binary WASM modules that aren't
directly fetched but at least we don't error anymore
  • Loading branch information
Lms24 committed May 31, 2023
1 parent 8482c0a commit 78454aa
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/wasm/src/registry.ts
Expand Up @@ -45,11 +45,22 @@ export function registerModule(module: WebAssembly.Module, url: string): void {
if (oldIdx >= 0) {
IMAGES.splice(oldIdx, 1);
}

let debugFileUrl = null;
if (debugFile) {
try {
debugFileUrl = new URL(debugFile, url).href;
} catch {
// debugFile could be a blob URL which causes the URL constructor to throw
// for now we just ignore this case
}
}

IMAGES.push({
type: 'wasm',
code_id: buildId,
code_file: url,
debug_file: debugFile ? new URL(debugFile, url).href : null,
debug_file: debugFileUrl,
debug_id: `${buildId.padEnd(32, '0').slice(0, 32)}0`,
});
}
Expand Down

0 comments on commit 78454aa

Please sign in to comment.