MCPcopy
hub / github.com/angular/angular / scheduleInitialization

Method scheduleInitialization

packages/service-worker/worker/src/driver.ts:958–973  ·  view source on GitHub ↗

* Schedule the SW's attempt to reach a fully prefetched state for the given AppVersion * when the SW is not busy and has connectivity. This returns a Promise which must be * awaited, as under some conditions the AppVersion might be initialized immediately.

(appVersion: AppVersion)

Source from the content-addressed store, hash-verified

956 * awaited, as under some conditions the AppVersion might be initialized immediately.
957 */
958 private async scheduleInitialization(appVersion: AppVersion): Promise<void> {
959 const initialize = async () => {
960 try {
961 await appVersion.initializeFully();
962 } catch (err: any) {
963 this.debugger.log(err, `initializeFully for ${appVersion.manifestHash}`);
964 await this.versionFailed(appVersion, err);
965 }
966 };
967
968 if (isLocalhost(this.scope.registration.scope)) {
969 return initialize();
970 }
971
972 this.idle.schedule(`initialization(${appVersion.manifestHash})`, initialize);
973 }
974
975 private async versionFailed(appVersion: AppVersion, err: Error): Promise<void> {
976 // This particular AppVersion is broken. First, find the manifest hash.

Callers 1

initializeMethod · 0.95

Calls 3

isLocalhostFunction · 0.85
initializeFunction · 0.50
scheduleMethod · 0.45

Tested by

no test coverage detected