update PR
This commit is contained in:
parent
a8dbc0fdd8
commit
d07d8f0fbe
|
|
@ -76,7 +76,7 @@ async function doFetch(event: FetchEvent): Promise<Response> {
|
|||
return fetch(event.request);
|
||||
|
||||
const request = event.request;
|
||||
const client = await self.clients.get(event.clientId);
|
||||
const client = await self.clients.get(event.clientId ?? event.resultingClientId);
|
||||
|
||||
// When trace viewer is deployed over https, we will force upgrade
|
||||
// insecure http subresources to https. Otherwise, these will fail
|
||||
|
|
@ -96,6 +96,9 @@ async function doFetch(event: FetchEvent): Promise<Response> {
|
|||
const traceUrl = url.searchParams.get('trace');
|
||||
|
||||
if (relativePath.startsWith('/snapshot/')) {
|
||||
// while there's no snapshot, the iframe keeps polling but isn't yet initialised.
|
||||
// `event.resultingClientId` will contain an ID, but it won't yet be available in `self.clients`.
|
||||
// so `client` will be undefined in that state.
|
||||
const { snapshotServer } = loadedTraces.get(traceUrl!) || {};
|
||||
if (!snapshotServer)
|
||||
return new Response(null, { status: 404 });
|
||||
|
|
@ -105,13 +108,6 @@ async function doFetch(event: FetchEvent): Promise<Response> {
|
|||
return response;
|
||||
}
|
||||
|
||||
if (relativePath.startsWith('/closest-screenshot/')) {
|
||||
const { snapshotServer } = loadedTraces.get(traceUrl!) || {};
|
||||
if (!snapshotServer)
|
||||
return new Response(null, { status: 404 });
|
||||
return snapshotServer.serveClosestScreenshot(relativePath, url.searchParams);
|
||||
}
|
||||
|
||||
if (!client) {
|
||||
// vscode webview doesn't sent clientId under some circumstances
|
||||
if (url.pathname.endsWith('embedded.html'))
|
||||
|
|
@ -144,6 +140,13 @@ async function doFetch(event: FetchEvent): Promise<Response> {
|
|||
return snapshotServer.serveSnapshotInfo(relativePath, url.searchParams);
|
||||
}
|
||||
|
||||
if (relativePath.startsWith('/closest-screenshot/')) {
|
||||
const { snapshotServer } = loadedTraces.get(traceUrl!) || {};
|
||||
if (!snapshotServer)
|
||||
return new Response(null, { status: 404 });
|
||||
return snapshotServer.serveClosestScreenshot(relativePath, url.searchParams);
|
||||
}
|
||||
|
||||
if (relativePath.startsWith('/sha1/')) {
|
||||
// Sha1 for sources is based on the file path, can't load it of a random model.
|
||||
const sha1 = relativePath.slice('/sha1/'.length);
|
||||
|
|
|
|||
Loading…
Reference in a new issue