{"record":{"id":"67111497beb83880","repo":"RocketChat/Rocket.Chat","slug":"apps-engine-not-loaded","errorCode":null,"errorMessage":"apps-engine-not-loaded","messagePattern":"apps-engine-not-loaded","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/api/v1/omnichannel/lib/outbound.ts","lineNumber":48,"sourceCode":"\t\tif (type !== undefined && !this.isProviderValid(type)) {\n\t\t\tthrow new Error('Invalid type');\n\t\t}\n\n\t\treturn this.provider.getOutboundMessageProviders(type);\n\t}\n\n\tpublic getProviderMetadata(providerId: string): Promise<IOutboundProviderMetadata> {\n\t\tconst provider = this.provider.findOneByProviderId(providerId);\n\t\tif (!provider) {\n\t\t\tthrow new Error('error-invalid-provider');\n\t\t}\n\n\t\treturn this.getProviderManager().getProviderMetadata(provider.appId, provider.type);\n\t}\n\n\tprivate getProviderManager() {\n\t\tif (!Apps.self?.isLoaded()) {\n\t\t\tthrow new Error('apps-engine-not-loaded');\n\t\t}\n\n\t\tconst manager = Apps.self?.getManager()?.getOutboundCommunicationProviderManager();\n\t\tif (!manager) {\n\t\t\tthrow new Error('apps-engine-not-configured-correctly');\n\t\t}\n\n\t\treturn manager;\n\t}\n\n\tpublic sendMessage(providerId: string, message: IOutboundMessage) {\n\t\tconst provider = this.provider.findOneByProviderId(providerId);\n\t\tif (!provider) {\n\t\t\tthrow new Error('error-invalid-provider');\n\t\t}\n\n\t\treturn this.getProviderManager().sendOutboundMessage(provider.appId, provider.type, message);\n\t}","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/api/v1/omnichannel/lib/outbound.ts#L30-L66","documentation":"Thrown by OutboundMessageProviderService.getProviderManager when Apps.self is not loaded (Apps.self?.isLoaded() returns falsy). The Apps Engine must finish loading before any outbound provider manager operation can run. Plain Error, code 'apps-engine-not-loaded'.","triggerScenarios":"Calling getProviderMetadata/sendMessage during server startup before the Apps Engine has finished initializing, or after the engine failed to load. Also reachable via code paths invoked very early in boot.","commonSituations":"Startup race: an omnichannel init hook or a deferred job fires before Apps Engine load completes; Apps Engine disabled or crashed during boot; calling from a migration that runs pre-engine.","solutions":["Defer the outbound call until the Apps Engine reports loaded (listen for the apps-engine loaded event / Apps.self.isLoaded()).","Check Apps.self?.isLoaded() before calling and queue/retry if false.","Inspect server logs for Apps Engine load failures and resolve those first.","Avoid invoking outbound operations from boot-time migrations."],"exampleFix":"// before: call during boot\napp.onServerStart(() => svc.getProviderMetadata(id));\n\n// after: wait for the engine\nif (!Apps.self?.isLoaded()) {\n  await waitForAppsEngineLoaded();\n}\nsvc.getProviderMetadata(id);","handlingStrategy":"retry","validationCode":"// Probe Apps Engine load state before calling\nimport { Apps } from '@rocket.chat/apps';\nfunction appsEngineReady(): boolean {\n  return !!Apps.self?.isLoaded();\n}\nif (!appsEngineReady()) {\n  // queue the call until loaded, or warn\n  throw new Error('Apps Engine not loaded yet');\n}","typeGuard":"function appsEngineLoaded(apps: typeof Apps): boolean {\n  return !!apps.self?.isLoaded();\n}","tryCatchPattern":"async function withAppsEngineReady<T>(fn: () => T | Promise<T>): Promise<T> {\n  try {\n    return await fn();\n  } catch (e) {\n    if (e.message === 'apps-engine-not-loaded') {\n      await waitForAppsEngineLoaded();\n      return fn();\n  }\n    throw e;\n  }\n}","preventionTips":["Do not call outbound operations from boot-time hooks; wait for the apps-engine loaded event.","Expose an apps-engine readiness signal to omnichannel init code."],"tags":["apps-engine","outbound","lifecycle","startup"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}