Skip to content

Commit

Permalink
fix(api/service-worker/worker.js): fix missing 'context' in install e…
Browse files Browse the repository at this point in the history
…vent
  • Loading branch information
jwerle committed Dec 10, 2024
1 parent 3d5db07 commit 0fa9b12
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions api/service-worker/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,7 @@ export async function onMessage (event) {

// import module, which could be ESM, CommonJS,
// or a simple ServiceWorker
const result = await import(scriptURL)

if (typeof module.exports === 'function') {
module.exports = {
default: module.exports
}
} else {
Object.assign(module.exports, result)
}
Object.assign(module.exports, await import(scriptURL))

state.serviceWorker.state = 'registered'
await state.notify('serviceWorker')
Expand Down Expand Up @@ -249,7 +241,7 @@ export async function onMessage (event) {
if (typeof state.activate === 'function') {
globalThis.addEventListener('activate', async (event) => {
try {
const promise = state.activate(event.context.env, event.ontext)
const promise = state.activate(event.context.env, event.context)
event.waitUntil(promise)
await promise
} catch (err) {
Expand Down

0 comments on commit 0fa9b12

Please sign in to comment.