{"record":{"id":"0ec4bf4f938fd6da","repo":"RocketChat/Rocket.Chat","slug":"error-unregistering-provider","errorCode":null,"errorMessage":"error-unregistering-provider","messagePattern":"error-unregistering-provider","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/outboundCommunication.ts","lineNumber":42,"sourceCode":"\t}\n\n\tprotected async registerEmailProvider(provider: IOutboundEmailMessageProvider, appId: string): Promise<void> {\n\t\ttry {\n\t\t\tthis.orch.debugLog(`App ${appId} is registering an email outbound provider.`);\n\t\t\tgetOutboundService().outboundMessageProvider.registerEmailProvider(provider);\n\t\t} catch (err) {\n\t\t\tthis.orch.getRocketChatLogger().error({ appId, err, msg: 'Failed to register email provider' });\n\t\t\tthrow new Error('error-registering-provider');\n\t\t}\n\t}\n\n\tprotected async unRegisterProvider(provider: IOutboundMessageProviders, appId: string): Promise<void> {\n\t\ttry {\n\t\t\tthis.orch.debugLog(`App ${appId} is unregistering an outbound provider.`);\n\t\t\tgetOutboundService().outboundMessageProvider.unregisterProvider(appId, provider.type);\n\t\t} catch (err) {\n\t\t\tthis.orch.getRocketChatLogger().error({ appId, err, msg: 'Failed to unregister provider' });\n\t\t\tthrow new Error('error-unregistering-provider');\n\t\t}\n\t}\n}\n","sourceCodeStart":24,"sourceCodeEnd":46,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/app/apps/server/bridges/outboundCommunication.ts#L24-L46","documentation":"AppOutboundCommunicationBridge.unRegisterProvider wraps getOutboundService().outboundMessageProvider.unregisterProvider(appId, provider.type) in try/catch; failures are logged as 'Failed to unregister provider' with the original error and re-thrown as 'error-unregistering-provider'. As with registration, the exception text is generic — the server log carries the root cause.","triggerScenarios":"Unregistering a provider that was never registered (e.g. disable handler runs when registration failed earlier); provider.type mismatch between register and unregister calls; the outbound service already torn down (shutdown order).","commonSituations":"onDisable/onUninstall handlers that assume registration succeeded; apps keeping provider objects that were mutated; server restarts where in-memory registry state was lost but the app still tries to unregister.","solutions":["Check the server log for 'Failed to unregister provider' and the underlying err","Only unregister providers you successfully registered (track registration state in the app)","Make register/unregister use the same provider.type value","Treat unregister failure as non-fatal during teardown when the registry is already empty"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const registered = new Set<string>();\nconst unregisterTracked = async (provider: { type: string }) => {\n  if (!registered.has(provider.type)) return; // nothing to unregister\n  await app.getRocketChat().getOutboundCommunication().unRegisterProvider(provider);\n  registered.delete(provider.type);\n};","typeGuard":null,"tryCatchPattern":"try {\n  await app.getRocketChat().getOutboundCommunication().unRegisterProvider(provider);\n} catch (err) {\n  if (err instanceof Error && err.message === 'error-unregistering-provider') {\n    // non-fatal during teardown; real cause logged server-side\n    app.getLogger().warn('provider unregister failed; continuing teardown');\n    return;\n  }\n  throw err;\n}","preventionTips":["Only unregister what you registered — mirror register calls with a state set","Use the identical provider.type value in register and unregister paths","Treat teardown-time unregister failures as warnings, not crashes","Re-check server logs for the underlying 'Failed to unregister provider' entry"],"tags":["apps-engine","outbound-communication","provider","unregistration","wrapped-error"],"backgroundTag":"provider-registration-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}