diff --git a/aio/src/app/layout/doc-viewer/doc-viewer.component.ts b/aio/src/app/layout/doc-viewer/doc-viewer.component.ts index bb531dc36ca..5d95a8c26a3 100644 --- a/aio/src/app/layout/doc-viewer/doc-viewer.component.ts +++ b/aio/src/app/layout/doc-viewer/doc-viewer.component.ts @@ -156,13 +156,6 @@ export class DocViewerComponent implements OnDestroy { this.nextViewContainer.textContent = ''; this.setNoIndex(true); - // TODO(gkalpak): Remove this once gathering debug info is no longer needed. - if (/loading chunk \S+ failed/i.test(errorMessage)) { - // Print some info to help with debugging. - // (There is no reason to wait for this async call to complete before continuing.) - printSwDebugInfo(); - } - return this.void$; }), ); @@ -268,84 +261,3 @@ export class DocViewerComponent implements OnDestroy { ); } } - -// Helpers -/** - * Print some info regarding the ServiceWorker and the caches contents to help debugging potential - * issues with failing to find resources in the cache. - * (See https://github.com/angular/angular/issues/28114.) - */ -async function printSwDebugInfo(): Promise { - const sep = '\n----------'; - const swState = navigator.serviceWorker?.controller?.state ?? 'N/A'; - - console.log(`\nServiceWorker: ${swState}`); - - if (typeof caches === 'undefined') { - console.log(`${sep}\nCaches: N/A`); - } else { - const allCacheNames = await caches.keys(); - const swCacheNames = allCacheNames.filter(name => name.startsWith('ngsw:/:')); - - await findCachesAndPrintEntries(swCacheNames, 'db:control', true, ['manifests']); - await findCachesAndPrintEntries(swCacheNames, 'assets:app-shell:cache', false); - await findCachesAndPrintEntries(swCacheNames, 'assets:app-shell:meta', true); - } - - if (swState === 'activated') { - console.log(sep); - await fetchAndPrintSwInternalDebugInfo(); - } - - console.warn( - `${sep}\nIf you see this error, please report an issue at ` + - 'https://github.com/angular/angular/issues/new?template=3-docs-bug.md including the above logs.'); - - // Internal helpers - async function fetchAndPrintSwInternalDebugInfo() { - try { - const res = await fetch('/ngsw/state'); - if (!res.ok) { - throw new Error(`Response ${res.status} ${res.statusText}`); - } - console.log(await res.text()); - } catch (err) { - console.log( - `Failed to retrieve debug info from '/ngsw/state': ${(err as Error).message || err}`); - } - } - - async function findCachesAndPrintEntries( - swCacheNames: string[], nameSuffix: string, includeValues: boolean, - ignoredKeys: string[] = []): Promise { - const cacheNames = swCacheNames.filter(name => name.endsWith(nameSuffix)); - - for (const cacheName of cacheNames) { - const cacheEntries = await getCacheEntries(cacheName, includeValues, ignoredKeys); - await printCacheEntries(cacheName, cacheEntries); - } - } - - async function getCacheEntries(name: string, includeValues: boolean, ignoredKeys: string[] = []): - Promise<{key: string, value?: unknown}[]> { - const ignoredUrls = new Set(ignoredKeys.map(key => new Request(key).url)); - - const cache = await caches.open(name); - const keys = (await cache.keys()).map(req => req.url).filter(url => !ignoredUrls.has(url)); - const entries = await Promise.all( - keys.map(async key => ({ - key, - value: !includeValues ? undefined : await (await cache.match(key))?.json(), - }))); - - return entries; - } - - function printCacheEntries(name: string, entries: {key: string, value?: unknown}[]): void { - const entriesStr = - entries.map(({key, value}) => ` - ${key}${!value ? '' : `: ${JSON.stringify(value)}`}`) - .join('\n'); - - console.log(`\nCache: ${name} (${entries.length} entries)\n${entriesStr}`); - } -} diff --git a/goldens/size-tracking/aio-payloads.json b/goldens/size-tracking/aio-payloads.json index 3a73502520f..a1bc168b630 100755 --- a/goldens/size-tracking/aio-payloads.json +++ b/goldens/size-tracking/aio-payloads.json @@ -2,7 +2,7 @@ "aio": { "uncompressed": { "runtime": 4325, - "main": 457028, + "main": 454820, "polyfills": 33814, "styles": 73640, "light-theme": 78276, @@ -12,7 +12,7 @@ "aio-local": { "uncompressed": { "runtime": 4325, - "main": 457651, + "main": 455179, "polyfills": 33922, "styles": 73640, "light-theme": 78045,