// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. import * as path from 'node:path'; import type { GetInputsSnapshotAsyncFn, IInputsSnapshot, IOperationExecutionResult, IOperationGraph, Operation, RushConfiguration, RushConfigurationProject, RushSession } from '@microsoft/rush-lib'; import type { CreateWorkspaceSessionComponentsAsync, ICreateWorkspaceSessionComponentsOptions, IWorkspaceSessionComponents } from './WorkspaceSession'; import type { IWorkspaceInvalidationSnapshot, WorkspaceInvalidationTracker } from './WorkspaceInvalidationTracker'; // Rush's incremental execution guard keeps the base of an operation that is invalidated with this reason, because it // compares the operation's inputs itself (INPUTS_CHANGED_INVALIDATION_REASON in rush-lib). Keep the two in sync. const INVALIDATION_REASON: 'workspace-inputs-changed' = 'workspace-inputs-changed'; /** * The command-dependent phase and plugin shape used to construct a reusable engine graph. * * @remarks * The complete shape must be supplied by the integration that owns command/plugin initialization. * Rush does not currently expose a command-independent "all phases and plugins" shape. * * @beta */ export interface IWorkspaceEngineShape { readonly phaseNames: ReadonlyArray; readonly pluginNames: ReadonlyArray; } /** * Context for constructing real reusable Rush engine components. * * @beta */ export interface ICreateWorkspaceEngineComponentsOptions extends IWorkspaceEngineShape { /** Every project in the loaded Rush configuration. */ readonly projectSelection: ReadonlySet; readonly rushConfiguration: RushConfiguration; } /** * Real Rush engine state constructed by the command/plugin integration. * * @beta */ export interface IWorkspaceEngineComponents extends AsyncDisposable { /** * Stops the graph lifetime and awaits all iteration, runner, plugin, and snapshot resources. * * @remarks * The engine owner must implement this because the public `IOperationGraph` API does not * currently expose one deterministic shutdown operation. */ [Symbol.asyncDispose](): Promise; /** Optional native execution gate, acquired once for a coalesced iteration before reconciliation. */ readonly acquireExecutionLeaseAsync?: () => Promise; readonly getInputsSnapshotAsync: GetInputsSnapshotAsyncFn; readonly inputsSnapshot: IInputsSnapshot; readonly operationGraph: IOperationGraph; readonly rushSession: RushSession; } /** * Constructs reusable Rush engine state for an explicit graph shape. * * @beta */ export type CreateWorkspaceEngineComponentsAsync = ( options: ICreateWorkspaceEngineComponentsOptions ) => Promise; /** * Context for mapping watcher paths onto operations in a constructed graph. * * @beta */ export interface IMapWorkspaceInvalidationsOptions { readonly changedPaths: ReadonlyArray; readonly currentInputsSnapshot: IInputsSnapshot; /** * The records of the executing iteration, if the operations are mapped to add another request's work to it. * * @remarks * The caller may then discard the result, so the mapper must keep any state that a later mapping of the same * changes needs. The iteration may be running some operations, which may be writing their outputs, and may * already have run others. */ readonly executingIterationRecords?: ReadonlyMap; readonly nextInputsSnapshot: IInputsSnapshot; readonly operationGraph: IOperationGraph; } /** * Context for identifying changes that require a new workspace engine. * * @beta */ export interface IClassifyWorkspaceInvalidationsOptions { readonly changedPaths: ReadonlyArray; readonly rushConfiguration: RushConfiguration; } /** * Identifies integration-specific graph inputs that cannot be reconciled against an existing graph. * * @remarks * Rush configuration files and project package manifests are classified automatically. Use this callback * for plugin-specific graph inputs outside those locations. * * @beta */ export type IsWorkspaceEngineRecreationRequiredAsync = ( options: IClassifyWorkspaceInvalidationsOptions ) => Promise; /** * Maps path-specific watcher invalidations onto operations in the reusable graph. * * @remarks * Unknown changes and unhealthy watcher state bypass this callback and invalidate the full graph. * * @beta */ export type MapWorkspaceInvalidationsToOperationsAsync = ( options: IMapWorkspaceInvalidationsOptions ) => Promise>; /** * The result of reconciling retained watcher invalidations with the engine snapshot. * * @beta */ export interface IWorkspaceInvalidationReconciliation { readonly inputsSnapshot: IInputsSnapshot; readonly invalidatedOperationCount: number; readonly isFullInvalidation: boolean; readonly sequence: number; } /** * Options for reading retained watcher invalidations for an iteration that is executing. * * @beta */ export interface IPeekWorkspaceInvalidationsOptions { /** The records of the executing iteration, which another request's work would be added to. */ readonly executingIterationRecords: ReadonlyMap; } /** * Retained watcher invalidations that were mapped onto operations without applying them to the graph, so that * another request's work can be added to an executing iteration. * * @remarks * Until the caller commits or discards it, no other reconciliation starts. * * @beta */ export interface IWorkspaceInvalidationPeek { /** The newer inputs snapshot, which the invalidations were mapped against. */ readonly inputsSnapshot: IInputsSnapshot; /** The operations whose inputs or outputs changed since the engine's inputs snapshot. */ readonly invalidatedOperations: ReadonlySet; /** The reason with which the caller invalidates `invalidatedOperations` in the graph. */ readonly invalidationReason: string; /** * Makes `inputsSnapshot` the engine's inputs snapshot and acknowledges the invalidations, once the caller * invalidated `invalidatedOperations` in the graph. */ commit(): void; /** Leaves the engine's inputs snapshot and the invalidations unchanged. */ discard(): void; } /** * Indicates that retained changes require the owning workspace session to be recreated. * * @remarks * The invalidations remain unacknowledged. Callers must not execute the existing operation graph after * receiving this error. * * @beta */ export class WorkspaceEngineRecreationRequiredError extends Error { public constructor() { super('Workspace changes require the reusable engine and session to be recreated.'); this.name = 'WorkspaceEngineRecreationRequiredError'; } } /** * Options for {@link WorkspaceEngineComponentFactory}. * * @beta */ export interface IWorkspaceEngineComponentFactoryOptions { readonly createEngineComponentsAsync: CreateWorkspaceEngineComponentsAsync; readonly isEngineRecreationRequiredAsync?: IsWorkspaceEngineRecreationRequiredAsync; readonly mapInvalidationsToOperationsAsync: MapWorkspaceInvalidationsToOperationsAsync; readonly shape: IWorkspaceEngineShape; /** * Refresh inputs even without a watcher notification (for request-time freshness). * * @remarks * The inputs snapshot is then taken while the graph inputs are validated. If the validation fails, the * reconciliation waits for the snapshot to finish, and discards it. */ readonly refreshInputsOnEveryRequest?: boolean; /** Authoritative graph-definition validation, awaited on every reconciliation before trusting path hints. */ readonly validateGraphInputsAsync?: () => Promise; } interface IWorkspaceEngineLifecycleOptions { readonly components: IWorkspaceEngineComponents; readonly graphDefiningPaths: IGraphDefiningPaths; readonly invalidations: WorkspaceInvalidationTracker; readonly isEngineRecreationRequiredAsync: IsWorkspaceEngineRecreationRequiredAsync | undefined; readonly mapInvalidationsToOperationsAsync: MapWorkspaceInvalidationsToOperationsAsync; readonly rushConfiguration: RushConfiguration; readonly refreshInputsOnEveryRequest: boolean; readonly validateGraphInputsAsync: (() => Promise) | undefined; } interface IGraphDefiningPaths { readonly filePaths: ReadonlySet; readonly folderPaths: ReadonlyArray; } class WorkspaceEngineLifecycle { readonly #components: IWorkspaceEngineComponents; readonly #graphDefiningPaths: IGraphDefiningPaths; readonly #invalidations: WorkspaceInvalidationTracker; readonly #isEngineRecreationRequiredAsync: IsWorkspaceEngineRecreationRequiredAsync | undefined; readonly #mapInvalidationsToOperationsAsync: MapWorkspaceInvalidationsToOperationsAsync; readonly #rushConfiguration: RushConfiguration; readonly #refreshInputsOnEveryRequest: boolean; readonly #validateGraphInputsAsync: (() => Promise) | undefined; #currentInputsSnapshot: IInputsSnapshot; #disposePromise: Promise | undefined; #isDisposing: boolean = false; #reconciliationTail: Promise = Promise.resolve(); #requiresFullInvalidation: boolean = false; public constructor(options: IWorkspaceEngineLifecycleOptions) { this.#components = options.components; this.#graphDefiningPaths = options.graphDefiningPaths; this.#currentInputsSnapshot = options.components.inputsSnapshot; this.#invalidations = options.invalidations; this.#isEngineRecreationRequiredAsync = options.isEngineRecreationRequiredAsync; this.#mapInvalidationsToOperationsAsync = options.mapInvalidationsToOperationsAsync; this.#rushConfiguration = options.rushConfiguration; this.#refreshInputsOnEveryRequest = options.refreshInputsOnEveryRequest; this.#validateGraphInputsAsync = options.validateGraphInputsAsync; } public get inputsSnapshot(): IInputsSnapshot { return this.#currentInputsSnapshot; } public reconcileInvalidationsAsync(): Promise { if (this.#isDisposing) { return Promise.reject(new Error('The workspace engine is being disposed.')); } const reconciliationPromise: Promise = this.#reconciliationTail.then(() => this.#reconcileOnceAsync()); this.#reconciliationTail = reconciliationPromise.then( () => undefined, () => undefined ); return reconciliationPromise; } /** * Maps the retained invalidations onto operations as a reconciliation would, without invalidating them in the * graph, acknowledging them or replacing the inputs snapshot. * * @remarks * Returns undefined if the changes invalidate every operation. Throws, leaving the invalidations retained, where a * reconciliation would throw. Later reconciliations wait until the returned peek is committed or discarded. */ public peekInvalidationsAsync( options: IPeekWorkspaceInvalidationsOptions ): Promise { if (this.#isDisposing) { return Promise.reject(new Error('The workspace engine is being disposed.')); } let settle: () => void = noop; const settled: Promise = new Promise((resolve: () => void) => { settle = resolve; }); const peekPromise: Promise = this.#reconciliationTail.then(() => this.#peekOnceAsync(options, settle) ); this.#reconciliationTail = peekPromise.then( (peek: IWorkspaceInvalidationPeek | undefined) => (peek ? settled : undefined), () => undefined ); return peekPromise; } public [Symbol.asyncDispose](): Promise { this.#isDisposing = true; this.#disposePromise ??= this.#disposeOnceAsync(); return this.#disposePromise; } async #reconcileOnceAsync(): Promise { // Read before the inputs, so that the inputs snapshot includes each change that this reconciliation acknowledges const invalidationSnapshot: IWorkspaceInvalidationSnapshot = this.#invalidations.getSnapshot(); const nextInputsSnapshotPromise: Promise | undefined = this.#startInputsSnapshot(); await this.#checkInvalidationsAsync(invalidationSnapshot, nextInputsSnapshotPromise); const isFullInvalidation: boolean = this.#isFullInvalidation(invalidationSnapshot); if ( !this.#refreshInputsOnEveryRequest && !isFullInvalidation && invalidationSnapshot.changedPaths.length === 0 ) { return { inputsSnapshot: this.#currentInputsSnapshot, invalidatedOperationCount: 0, isFullInvalidation: false, sequence: invalidationSnapshot.sequence }; } const nextInputsSnapshot: IInputsSnapshot = await this.#getNextInputsSnapshotAsync(nextInputsSnapshotPromise); const operationGraph: IOperationGraph = this.#components.operationGraph; let invalidatedOperationCount: number; if (isFullInvalidation) { operationGraph.invalidateOperations(undefined, INVALIDATION_REASON); invalidatedOperationCount = operationGraph.operations.size; } else { const invalidatedOperations: ReadonlySet = await this.#mapInvalidationsAsync( invalidationSnapshot, nextInputsSnapshot, undefined ); operationGraph.invalidateOperations(invalidatedOperations, INVALIDATION_REASON); invalidatedOperationCount = invalidatedOperations.size; } this.#acknowledge(invalidationSnapshot, nextInputsSnapshot); return { inputsSnapshot: nextInputsSnapshot, invalidatedOperationCount, isFullInvalidation, sequence: invalidationSnapshot.sequence }; } async #peekOnceAsync( options: IPeekWorkspaceInvalidationsOptions, settle: () => void ): Promise { const invalidationSnapshot: IWorkspaceInvalidationSnapshot = this.#invalidations.getSnapshot(); const nextInputsSnapshotPromise: Promise | undefined = this.#startInputsSnapshot(); await this.#checkInvalidationsAsync(invalidationSnapshot, nextInputsSnapshotPromise); if (this.#isFullInvalidation(invalidationSnapshot)) { // Invalidating every operation would also invalidate those that the iteration already ran await nextInputsSnapshotPromise?.then(noop, noop); return undefined; } let isSettled: boolean = false; const settleOnce = (): void => { if (isSettled) { throw new Error('The workspace invalidation peek was already committed or discarded.'); } isSettled = true; settle(); }; if (!this.#refreshInputsOnEveryRequest && invalidationSnapshot.changedPaths.length === 0) { return { inputsSnapshot: this.#currentInputsSnapshot, invalidatedOperations: new Set(), invalidationReason: INVALIDATION_REASON, commit: settleOnce, discard: settleOnce }; } const nextInputsSnapshot: IInputsSnapshot = await this.#getNextInputsSnapshotAsync(nextInputsSnapshotPromise); const invalidatedOperations: ReadonlySet = await this.#mapInvalidationsAsync( invalidationSnapshot, nextInputsSnapshot, options.executingIterationRecords ); return { inputsSnapshot: nextInputsSnapshot, invalidatedOperations, invalidationReason: INVALIDATION_REASON, commit: () => { settleOnce(); this.#acknowledge(invalidationSnapshot, nextInputsSnapshot); }, discard: settleOnce }; } /** * A reconciliation that refreshes the inputs reads them in any case, so it starts reading them before the * checks, which run meanwhile. */ #startInputsSnapshot(): Promise | undefined { return this.#refreshInputsOnEveryRequest ? this.#components.getInputsSnapshotAsync() : undefined; } /** Validates the graph inputs, and throws if the invalidations require a new engine. */ async #checkInvalidationsAsync( invalidationSnapshot: IWorkspaceInvalidationSnapshot, nextInputsSnapshotPromise: Promise | undefined ): Promise { // The snapshot may fail before the checks finish, which must not be reported as an unhandled rejection const nextInputsSnapshotSettledPromise: Promise | undefined = nextInputsSnapshotPromise?.then( noop, noop ); try { await this.#validateGraphInputsAsync?.(); if (await this.#requiresEngineRecreationAsync(invalidationSnapshot)) { throw new WorkspaceEngineRecreationRequiredError(); } } catch (error) { // No command may still read the inputs once the reconciliation failed await nextInputsSnapshotSettledPromise; throw error; } } #isFullInvalidation(invalidationSnapshot: IWorkspaceInvalidationSnapshot): boolean { return ( this.#requiresFullInvalidation || invalidationSnapshot.hasUnknownChanges || !invalidationSnapshot.isWatcherHealthy ); } async #getNextInputsSnapshotAsync( nextInputsSnapshotPromise: Promise | undefined ): Promise { const nextInputsSnapshot: IInputsSnapshot | undefined = await (nextInputsSnapshotPromise ?? this.#components.getInputsSnapshotAsync()); if (!nextInputsSnapshot) { throw new Error('Rush could not capture the next workspace inputs snapshot.'); } return nextInputsSnapshot; } async #mapInvalidationsAsync( invalidationSnapshot: IWorkspaceInvalidationSnapshot, nextInputsSnapshot: IInputsSnapshot, executingIterationRecords: ReadonlyMap | undefined ): Promise> { const operationGraph: IOperationGraph = this.#components.operationGraph; const mappedOperations: Iterable = await this.#mapInvalidationsToOperationsAsync({ changedPaths: invalidationSnapshot.changedPaths, currentInputsSnapshot: this.#currentInputsSnapshot, ...(executingIterationRecords ? { executingIterationRecords } : {}), nextInputsSnapshot, operationGraph }); return validateMappedOperations(mappedOperations, operationGraph); } #acknowledge( invalidationSnapshot: IWorkspaceInvalidationSnapshot, nextInputsSnapshot: IInputsSnapshot ): void { this.#currentInputsSnapshot = nextInputsSnapshot; this.#invalidations.acknowledgeThrough(invalidationSnapshot.sequence); this.#requiresFullInvalidation = !this.#refreshInputsOnEveryRequest && this.#invalidations.getSnapshot().sequence > invalidationSnapshot.sequence; } async #disposeOnceAsync(): Promise { await this.#reconciliationTail; await this.#components[Symbol.asyncDispose](); } async #requiresEngineRecreationAsync( invalidationSnapshot: IWorkspaceInvalidationSnapshot ): Promise { if ( invalidationSnapshot.changedPaths.length === 0 && !invalidationSnapshot.hasUnknownChanges && invalidationSnapshot.isWatcherHealthy ) { return false; } if (this.#invalidations.hasUnattributedUnknownChanges || !invalidationSnapshot.isWatcherHealthy) { return true; } if ( !this.#validateGraphInputsAsync && invalidationSnapshot.changedPaths.some((changedPath: string) => isBuiltInGraphDefiningPath( changedPath, this.#rushConfiguration.rushJsonFolder, this.#graphDefiningPaths ) ) ) { return true; } return ( (await this.#isEngineRecreationRequiredAsync?.({ changedPaths: invalidationSnapshot.changedPaths, rushConfiguration: this.#rushConfiguration })) ?? false ); } } /** * Adapts an explicitly shaped, all-project Rush engine into warm workspace session components. * * @remarks * The factory deliberately does not construct phased hooks or load plugins itself. Those choices remain * command-specific in Rush today, so their owner must provide the complete shape and construction callback. * * @beta */ export class WorkspaceEngineComponentFactory { readonly #createEngineComponentsAsync: CreateWorkspaceEngineComponentsAsync; readonly #isEngineRecreationRequiredAsync: IsWorkspaceEngineRecreationRequiredAsync | undefined; readonly #mapInvalidationsToOperationsAsync: MapWorkspaceInvalidationsToOperationsAsync; readonly #refreshInputsOnEveryRequest: boolean; readonly #validateGraphInputsAsync: (() => Promise) | undefined; public readonly createAsync: CreateWorkspaceSessionComponentsAsync; public readonly shape: IWorkspaceEngineShape; public constructor(options: IWorkspaceEngineComponentFactoryOptions) { this.#createEngineComponentsAsync = options.createEngineComponentsAsync; this.#isEngineRecreationRequiredAsync = options.isEngineRecreationRequiredAsync; this.#mapInvalidationsToOperationsAsync = options.mapInvalidationsToOperationsAsync; this.#refreshInputsOnEveryRequest = options.refreshInputsOnEveryRequest ?? false; this.#validateGraphInputsAsync = options.validateGraphInputsAsync; this.shape = normalizeShape(options.shape); this.createAsync = (createOptions: ICreateWorkspaceSessionComponentsOptions) => this.#createAsync(createOptions); } async #createAsync( options: ICreateWorkspaceSessionComponentsOptions ): Promise { const projects: ReadonlySet = new Set(options.rushConfiguration.projects); const graphDefiningPaths: IGraphDefiningPaths = createGraphDefiningPaths(options.rushConfiguration); const components: IWorkspaceEngineComponents = await this.#createEngineComponentsAsync({ phaseNames: this.shape.phaseNames, pluginNames: this.shape.pluginNames, projectSelection: projects, rushConfiguration: options.rushConfiguration }); try { validateComponents(components, options.rushConfiguration, this.shape); } catch (error) { await disposeAfterInitializationFailureAsync(components, error); } const lifecycle: WorkspaceEngineLifecycle = new WorkspaceEngineLifecycle({ components, graphDefiningPaths, invalidations: options.invalidations, isEngineRecreationRequiredAsync: this.#isEngineRecreationRequiredAsync, mapInvalidationsToOperationsAsync: this.#mapInvalidationsToOperationsAsync, rushConfiguration: options.rushConfiguration, refreshInputsOnEveryRequest: this.#refreshInputsOnEveryRequest, validateGraphInputsAsync: this.#validateGraphInputsAsync }); return { [Symbol.asyncDispose]: () => lifecycle[Symbol.asyncDispose](), acquireExecutionLeaseAsync: components.acquireExecutionLeaseAsync ? () => components.acquireExecutionLeaseAsync!() : undefined, engineShape: this.shape, get inputsSnapshot(): IInputsSnapshot { return lifecycle.inputsSnapshot; }, operationGraph: components.operationGraph, peekInvalidationsAsync: (peekOptions: IPeekWorkspaceInvalidationsOptions) => lifecycle.peekInvalidationsAsync(peekOptions), reconcileInvalidationsAsync: () => lifecycle.reconcileInvalidationsAsync(), rushSession: components.rushSession }; } } function createGraphDefiningPaths(rushConfiguration: RushConfiguration): IGraphDefiningPaths { const filePaths: Set = new Set([path.resolve(rushConfiguration.rushJsonFile)]); for (const project of rushConfiguration.projects) { filePaths.add(path.join(project.projectFolder, 'package.json')); filePaths.add(path.join(project.projectFolder, 'config', 'rush-project.json')); } return { filePaths, folderPaths: [ path.resolve(rushConfiguration.commonRushConfigFolder), ...Array.from(rushConfiguration.subspaces, (subspace) => path.resolve(subspace.getSubspaceConfigFolderPath()) ) ] }; } function isBuiltInGraphDefiningPath( changedPath: string, rushJsonFolder: string, graphDefiningPaths: IGraphDefiningPaths ): boolean { const absoluteChangedPath: string = path.resolve(rushJsonFolder, changedPath); if (graphDefiningPaths.filePaths.has(absoluteChangedPath)) { return true; } for (const folderPath of graphDefiningPaths.folderPaths) { if (isPathInside(absoluteChangedPath, folderPath)) { return true; } } return false; } function isPathInside(candidatePath: string, folderPath: string): boolean { const relativePath: string = path.relative(path.resolve(folderPath), candidatePath); return ( relativePath === '' || (!path.isAbsolute(relativePath) && relativePath !== '..' && !relativePath.startsWith(`..${path.sep}`)) ); } function normalizeShape(shape: IWorkspaceEngineShape): IWorkspaceEngineShape { return Object.freeze({ phaseNames: normalizeNames(shape.phaseNames, 'phase', true), pluginNames: normalizeNames(shape.pluginNames, 'plugin', false) }); } function normalizeNames( names: ReadonlyArray, kind: string, requireNonempty: boolean ): ReadonlyArray { if (requireNonempty && names.length === 0) { throw new Error(`The workspace engine ${kind} shape must not be empty.`); } const normalizedNames: Set = new Set(); for (const name of names) { if (name.length === 0 || name.trim() !== name) { throw new Error(`Invalid workspace engine ${kind} name: "${name}".`); } if (normalizedNames.has(name)) { throw new Error(`Duplicate workspace engine ${kind} name: "${name}".`); } normalizedNames.add(name); } return Object.freeze(Array.from(normalizedNames).sort()); } function validateComponents( components: IWorkspaceEngineComponents, rushConfiguration: RushConfiguration, shape: IWorkspaceEngineShape ): void { const operations: ReadonlySet = components.operationGraph.operations; if (operations.size === 0) { throw new Error('The reusable workspace operation graph must not be empty.'); } const configuredProjects: ReadonlySet = new Set(rushConfiguration.projects); const representedProjects: Set = new Set(); const phaseNames: ReadonlySet = new Set(shape.phaseNames); for (const operation of operations) { if (!configuredProjects.has(operation.associatedProject)) { throw new Error( `Operation "${operation.associatedPhase.name}" uses a project outside the loaded Rush configuration.` ); } if (!phaseNames.has(operation.associatedPhase.name)) { throw new Error( `Operation phase "${operation.associatedPhase.name}" is not declared in the workspace engine shape.` ); } representedProjects.add(operation.associatedProject); } for (const project of configuredProjects) { if (!representedProjects.has(project)) { throw new Error( `The reusable workspace operation graph does not represent project "${project.packageName}".` ); } } } function noop(): void { // Nothing to do } function validateMappedOperations( operations: Iterable, operationGraph: IOperationGraph ): ReadonlySet { const validatedOperations: Set = new Set(); for (const operation of operations) { if (!operationGraph.operations.has(operation)) { throw new Error('The workspace invalidation mapper returned an operation outside the graph.'); } validatedOperations.add(operation); } return validatedOperations; } async function disposeAfterInitializationFailureAsync( components: IWorkspaceEngineComponents, initializationError: unknown ): Promise { try { await components[Symbol.asyncDispose](); } catch (cleanupError) { throw new AggregateError( [initializationError, cleanupError], 'Failed to validate and clean up reusable workspace engine components.' ); } throw initializationError; }