This commit is contained in:
Nicolas Lepage 2021-01-22 00:14:22 +01:00
parent cc01a186e8
commit 0e553499b3
No known key found for this signature in database
GPG Key ID: B0879E35E66D8F6F

4
sw.js
View File

@ -15,7 +15,7 @@ function registerWasmHTTPListener(wasm, base, args = []) {
let path = new URL(registration.scope).pathname
if (base && base !== '') path = `${trimEnd(path, '/')}/${trimStart(base, '/')}`
const wasmPromise = fetch(wasm)
const wasmPromise = fetch(wasm).then(res => res.arrayBuffer())
addEventListener('fetch', e => {
const { pathname } = new URL(e.request.url)
@ -28,7 +28,7 @@ function registerWasmHTTPListener(wasm, base, args = []) {
go.env = { WASMHTTP_HANDLER_ID: handlerId, WASMHTTP_PATH: path }
go.argv = [wasm, ...args]
// FIXME await ? catch ?
WebAssembly.instantiateStreaming(wasmPromise, go.importObject).then(({ instance }) => go.run(instance))
WebAssembly.instantiate(wasmPromise, go.importObject).then(({ instance }) => go.run(instance))
e.respondWith(handlerPromise.then(handler => handler(e.request)))
})