{"record":{"id":"0ec4bf4f938fd6da","repo":"RocketChat/Rocket.Chat","slug":"error-unregistering-provider","errorCode":null,"errorMessage":"error-unregistering-provider","messagePattern":"error-unregistering-provider","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","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/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/app/apps/server/bridges/outboundCommunication.ts#L24-L46","documentation":"Generic wrapper thrown by OutboundCommunicationBridge.unRegisterProvider when getOutboundService().outboundMessageProvider.unregisterProvider throws. The original error is logged with msg 'Failed to unregister provider' before this opaque message is thrown. Signals that cleanup of a previously registered phone/email outbound provider failed.","triggerScenarios":"An App's disable/uninstall hook tries to unregister a provider that was never registered (e.g. registration failed earlier but disable still runs), the provider type does not match any registered one, or the outbound service is already torn down.","commonSituations":"Asymmetric register/unregister after a failed registration; calling unregister with the wrong type string; uninstall of an App whose onEnable never completed; server shutdown race where the outbound service is gone.","solutions":["Read the server log for the original `err` to see the concrete failure.","Track registration state in your App and only unregister what you successfully registered.","Make onDisable resilient: wrap unregister in try/catch and log, since failing to unregister should not break disable.","Ensure the type passed to unregister matches the type used at registration."],"exampleFix":"// before\nawait outbound.unRegisterProvider(provider, appId); // throws if never registered\n\n// after\nif (this.registered) {\n  try {\n    await outbound.unRegisterProvider(provider, appId);\n  } catch (e) {\n    console.warn(' unregister failed', e.message);\n  }\n  this.registered = false;\n}","handlingStrategy":"try-catch","validationCode":"// only unregister what you successfully registered\nif (!this.registeredTypes.has(provider.type)) {\n  this.app.getLogger().debug(`Skipping unregister for ${provider.type}: not registered`);\n  return;\n}\nawait outbound.unRegisterProvider(provider, appId);","typeGuard":null,"tryCatchPattern":"try {\n  await outbound.unRegisterProvider(provider, appId);\n  this.registeredTypes.delete(provider.type);\n} catch (e) {\n  // failing to unregister must not break disable\n  this.app.getLogger().warn({ msg: 'Unregister failed', providerType: provider.type, err: e });\n}","preventionTips":["Track registration state in your App and only unregister what you registered.","Always wrap unregister in try/catch so cleanup failures do not block disable.","Match the type string passed to unregister with the one used at registration."],"tags":["apps-engine","outbound-bridge","omnichannel","provider-registration","lifecycle","wrapped-error"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}