{"record":{"id":"0498c3d5ed2e43c4","repo":"RocketChat/Rocket.Chat","slug":"apps-engine-not-initialized","errorCode":"apps-engine-not-initialized","errorMessage":"apps-engine-not-initialized","messagePattern":"apps-engine-not-initialized","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/lib/license/canEnableApp.ts","lineNumber":15,"sourceCode":"import type { IAppStorageItem } from '@rocket.chat/apps/dist/server/storage/IAppStorageItem';\nimport { Apps } from '@rocket.chat/core-services';\nimport type { LicenseModule } from '@rocket.chat/core-typings';\nimport { License, type LicenseImp } from '@rocket.chat/license';\n\nimport { getInstallationSourceFromAppStorageItem } from '../../../../lib/apps/getInstallationSourceFromAppStorageItem';\n\ntype _canEnableAppDependencies = {\n\tApps: typeof Apps;\n\tLicense: LicenseImp;\n};\n\nexport const _canEnableApp = async ({ Apps, License }: _canEnableAppDependencies, app: IAppStorageItem): Promise<void> => {\n\tif (!(await Apps.isInitialized())) {\n\t\tthrow new Error('apps-engine-not-initialized');\n\t}\n\n\t// Migrated apps were installed before the validation was implemented\n\t// so they're always allowed to be enabled\n\tif (app.migrated) {\n\t\treturn;\n\t}\n\n\tif (app.info.addon && !License.hasModule(app.info.addon as LicenseModule)) {\n\t\tthrow new Error('app-addon-not-valid');\n\t}\n\n\tconst source = getInstallationSourceFromAppStorageItem(app);\n\tswitch (source) {\n\t\tcase 'private':\n\t\t\tif (await License.shouldPreventAction('privateApps')) {\n\t\t\t\tthrow new Error('license-prevented');\n\t\t\t}","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/lib/license/canEnableApp.ts#L1-L33","documentation":"Thrown by _canEnableApp (license/canEnableApp.ts:15) when Apps.isInitialized() returns false — the Apps Engine has not finished initializing. It is the first check in the enable-app gate, so it precedes any license/addon logic. Plain Error. Migrated apps are not exempt here because this check runs before the migrated-app short-circuit.","triggerScenarios":"Calling canEnableApp during server startup before the Apps Engine reports ready; the apps-engine microservice (apps-engine-migration) is not yet wired or has failed to start; an admin action races the boot sequence.","commonSituations":"Server just restarted and an admin/API call to enable an app landed too early; apps-engine service crashed or is unhealthy; running against a partially-initialized test fixture.","solutions":["Wait for the Apps Engine to finish initialization and retry the enable.","Check Apps Engine / apps-engine microservice health and logs for startup failures.","Guard the caller to only enable apps after the 'apps-engine-ready' signal."],"exampleFix":"// before\nawait canEnableApp(app); // may throw during boot\n\n// after\nif (!(await Apps.isInitialized())) {\n  return deferUntilAppsReady();\n}\nawait canEnableApp(app);","handlingStrategy":"validation","validationCode":"async function ensureAppsReady(): Promise<void> {\n  if (!(await Apps.isInitialized())) throw new Error('apps-engine-not-initialized');\n}","typeGuard":"null","tryCatchPattern":"try { await canEnableApp(app); } catch (e) {\n  if (e instanceof Error && e.message === 'apps-engine-not-initialized') { /* wait for ready signal, then retry */ } else throw e;\n}","preventionTips":["Defer app-enable operations until the Apps Engine reports initialized.","Health-check the apps-engine microservice before issuing app commands.","Avoid enabling apps during boot races."],"tags":["apps-engine","initialization","startup","enterprise"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}