Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wasm): Avoid throwing an error when WASM modules are loaded from blobs #8263

Merged
merged 1 commit into from May 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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