MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / patchWebAssembly

Function patchWebAssembly

packages/wasm/src/patchWebAssembly.ts:6–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4 * Patches the web assembly runtime.
5 */
6export function patchWebAssembly(): void {
7 if ('instantiateStreaming' in WebAssembly) {
8 const origInstantiateStreaming = WebAssembly.instantiateStreaming;
9 WebAssembly.instantiateStreaming = function instantiateStreaming(
10 response: Response | PromiseLike<Response>,
11 importObject: WebAssembly.Imports,
12 ): Promise<WebAssembly.Module> {
13 return Promise.resolve(response).then(response => {
14 return origInstantiateStreaming(response, importObject).then(rv => {
15 if (response.url) {
16 registerModule(rv.module, response.url);
17 }
18 return rv;
19 });
20 });
21 } as typeof WebAssembly.instantiateStreaming;
22 }
23
24 if ('compileStreaming' in WebAssembly) {
25 const origCompileStreaming = WebAssembly.compileStreaming;
26 WebAssembly.compileStreaming = function compileStreaming(
27 source: Response | Promise<Response>,
28 ): Promise<WebAssembly.Module> {
29 return Promise.resolve(source).then(response => {
30 return origCompileStreaming(response).then(module => {
31 if (response.url) {
32 registerModule(module, response.url);
33 }
34 return module;
35 });
36 });
37 } as typeof WebAssembly.compileStreaming;
38 }
39}

Callers 1

setupOnceFunction · 0.90

Calls 3

registerModuleFunction · 0.90
resolveMethod · 0.65
thenMethod · 0.45

Tested by

no test coverage detected