mirror of
https://github.com/nlepage/go-wasm-http-server.git
synced 2025-03-10 17:29:10 +00:00
⚗️
This commit is contained in:
parent
cc01a186e8
commit
0e553499b3
4
sw.js
4
sw.js
@ -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)))
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user