libresilient test deploy: Request() init cannot have "mode: navigate", it seems

merge-requests/9/merge
Michał 'rysiek' Woźniak 2021-11-16 18:40:14 +00:00
rodzic a8707f758b
commit 67f178924d
1 zmienionych plików z 35 dodań i 15 usunięć

Wyświetl plik

@ -233,9 +233,13 @@ let decrementActiveFetches = (clientId) => {
// got fetched) or not
self.clients.get(clientId).then((client)=>{
if (client !== null) {
client.postMessage({
allFetched: true
})
try {
client.postMessage({
allFetched: true
})
} catch(err) {
self.log("service-worker", `postMessage failed for client: ${client}\n- Error message: ${err}`)
}
}
})
.then(()=>{
@ -314,7 +318,11 @@ let LibResilientResourceInfo = class {
this.client = client
// Send a message to the client
if (this.client !== null) {
this.client.postMessage(this.values);
try {
this.client.postMessage(this.values);
} catch(err) {
self.log("service-worker", `postMessage failed for client: ${this.client}\n- Error message: ${err}`)
}
}
})
}
@ -347,7 +355,11 @@ let LibResilientResourceInfo = class {
self.log('service-worker', msg)
// send the message to the client
if (this.client && changed && (this.client !== null)) {
this.client.postMessage(this.values);
try {
this.client.postMessage(this.values);
} catch(err) {
self.log("service-worker", `postMessage failed for client: ${this.client}\n- Error message: ${err}`)
}
}
}
@ -407,7 +419,7 @@ let initFromRequest = (req) => {
return {
method: req.method,
headers: req.headers,
mode: req.mode,
mode: "cors", // req.mode, TODO: commented out because mode: navigate is haram in service worker, it seems
credentials: req.credentials,
cache: req.cache,
redirect: req.redirect,
@ -586,10 +598,14 @@ let getResourceThroughLibResilient = (request, clientId, useStashed=true, doStas
self.log('service-worker', 'fetched version method or ETag differs from stashed for:', url)
self.clients.get(reqInfo.clientId).then((client)=>{
if (client !== null) {
client.postMessage({
url: url,
fetchedDiffers: true
})
try {
client.postMessage({
url: url,
fetchedDiffers: true
})
} catch(err) {
self.log("service-worker", `postMessage failed for client: ${client}\n- Error message: ${err}`)
}
}
})
// TODO: this should probably modify doStash?
@ -687,11 +703,15 @@ self.addEventListener('fetch', event => {
.get(clientId)
.then((client)=>{
if (client !== null) {
client.postMessage({
clientId: clientId,
plugins: self.LibResilientPlugins.map((p)=>{return p.name}),
serviceWorker: 'COMMIT_UNKNOWN'
})
try {
client.postMessage({
clientId: clientId,
plugins: self.LibResilientPlugins.map((p)=>{return p.name}),
serviceWorker: 'COMMIT_UNKNOWN'
})
} catch(err) {
self.log("service-worker", `postMessage failed for client: ${client}\n- Error message: ${err}`)
}
}
})
}