* 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)
| 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. |
no test coverage detected