diff --git a/goldens/public-api/service-worker/index.api.md b/goldens/public-api/service-worker/index.api.md index 7c913453744..f6634186955 100644 --- a/goldens/public-api/service-worker/index.api.md +++ b/goldens/public-api/service-worker/index.api.md @@ -110,7 +110,7 @@ export interface VersionDetectedEvent { } // @public -export type VersionEvent = VersionDetectedEvent | VersionInstallationFailedEvent | VersionReadyEvent | VersionFailedEvent | NoNewVersionDetectedEvent; +export type VersionEvent = VersionDetectedEvent | VersionInstallationFailedEvent | VersionReadyEvent | NoNewVersionDetectedEvent; // @public export interface VersionInstallationFailedEvent { diff --git a/packages/service-worker/src/low_level.ts b/packages/service-worker/src/low_level.ts index 7a1443c2a79..b5ab39fa368 100644 --- a/packages/service-worker/src/low_level.ts +++ b/packages/service-worker/src/low_level.ts @@ -70,23 +70,6 @@ export interface VersionReadyEvent { latestVersion: {hash: string; appData?: object}; } -/** - * An event emitted when a specific version of the app has encountered a critical failure - * that prevents it from functioning correctly. - * - * When a version fails, the service worker will notify all clients currently using that version - * and may degrade to serving only existing clients if the failed version was the latest one. - * - * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide} - * - * @publicApi - */ -export interface VersionFailedEvent { - type: 'VERSION_FAILED'; - version: {hash: string; appData?: object}; - error: string; -} - /** * A union of all event types that can be emitted by * {@link SwUpdate#versionUpdates}. @@ -97,7 +80,6 @@ export type VersionEvent = | VersionDetectedEvent | VersionInstallationFailedEvent | VersionReadyEvent - | VersionFailedEvent | NoNewVersionDetectedEvent; /** diff --git a/packages/service-worker/src/update.ts b/packages/service-worker/src/update.ts index 283843f8c40..c341481ad94 100644 --- a/packages/service-worker/src/update.ts +++ b/packages/service-worker/src/update.ts @@ -69,7 +69,6 @@ export class SwUpdate { 'VERSION_INSTALLATION_FAILED', 'VERSION_READY', 'NO_NEW_VERSION_DETECTED', - 'VERSION_FAILED', ]); this.unrecoverable = this.sw.eventsOfType('UNRECOVERABLE_STATE'); } diff --git a/packages/service-worker/test/comm_spec.ts b/packages/service-worker/test/comm_spec.ts index ef490bacc0b..51d36f43569 100644 --- a/packages/service-worker/test/comm_spec.ts +++ b/packages/service-worker/test/comm_spec.ts @@ -13,7 +13,6 @@ import { NoNewVersionDetectedEvent, VersionDetectedEvent, VersionEvent, - VersionFailedEvent, VersionReadyEvent, } from '../src/low_level'; import {ngswCommChannelFactory, SwRegistrationOptions} from '../src/provider'; @@ -510,25 +509,6 @@ describe('ServiceWorker library', () => { }, }); }); - it('processes version failed events with cache corruption error', (done) => { - update.versionUpdates.subscribe((event) => { - expect(event.type).toEqual('VERSION_FAILED'); - expect((event as VersionFailedEvent).version).toEqual({ - hash: 'B', - appData: {name: 'test-app'}, - }); - expect((event as VersionFailedEvent).error).toContain('Cache corruption detected'); - done(); - }); - mock.sendMessage({ - type: 'VERSION_FAILED', - version: { - hash: 'B', - appData: {name: 'test-app'}, - }, - error: 'Cache corruption detected during resource fetch', - }); - }); it('activates updates when requested', async () => { mock.messages.subscribe((msg: {action: string; nonce: number}) => { expect(msg.action).toEqual('ACTIVATE_UPDATE'); diff --git a/packages/service-worker/worker/src/driver.ts b/packages/service-worker/worker/src/driver.ts index 7148a2503e3..df17e66505b 100644 --- a/packages/service-worker/worker/src/driver.ts +++ b/packages/service-worker/worker/src/driver.ts @@ -992,8 +992,7 @@ export class Driver implements Debuggable, UpdateSource { // Therefore, we keep clients on their current version (even if broken) and ensure that no new // clients will be assigned to it. - // Notify clients that are using this broken version about the failure. - await this.notifyClientsAboutVersionFailure(brokenHash, err); + // TODO: notify affected apps. // The action taken depends on whether the broken manifest is the active (latest) or not. // - If the broken version is not the latest, no further action is necessary, since new clients @@ -1335,29 +1334,6 @@ export class Driver implements Debuggable, UpdateSource { ); } - async notifyClientsAboutVersionFailure(brokenHash: string, error: Error): Promise { - await this.initialized; - - // Find all clients using the broken version - const affectedClients = Array.from(this.clientVersionMap.entries()) - .filter(([clientId, hash]) => hash === brokenHash) - .map(([clientId]) => clientId); - - await Promise.all( - affectedClients.map(async (clientId) => { - const client = await this.scope.clients.get(clientId); - if (client) { - const brokenVersion = this.versions.get(brokenHash); - client.postMessage({ - type: 'VERSION_FAILED', - version: this.mergeHashWithAppData(brokenVersion!.manifest, brokenHash), - error: errorToString(error), - }); - } - }), - ); - } - async broadcast(msg: Object): Promise { const clients = await this.scope.clients.matchAll(); clients.forEach((client) => { diff --git a/packages/service-worker/worker/test/happy_spec.ts b/packages/service-worker/worker/test/happy_spec.ts index 3731da14af5..0b791d021b0 100644 --- a/packages/service-worker/worker/test/happy_spec.ts +++ b/packages/service-worker/worker/test/happy_spec.ts @@ -2594,7 +2594,6 @@ import {envIsSupported} from '../testing/utils'; expect(await makeRequest(scope, '/foo.hash.js', 'client-2')).toBeNull(); expect(mockClient2.messages).toEqual([ jasmine.objectContaining({type: 'UNRECOVERABLE_STATE'}), - jasmine.objectContaining({type: 'VERSION_FAILED'}), ]); // This should also enter the `SW` into degraded mode, because the broken version was the