{"record":{"id":"361b4bd043d2923b","repo":"abpframework/abp","slug":"an-error-occurred-during-the-shutdown-contributor","errorCode":null,"errorMessage":"An error occurred during the shutdown {contributor.GetType().FullName} phase of the module {module.Type.AssemblyQualifiedName}: {ex.Message}. See the inner exception for details.","messagePattern":"An error occurred during the shutdown (.+?) phase of the module (.+?): (.+?)\\. See the inner exception for details\\.","errorType":"exception","errorClass":"AbpShutdownException","httpStatus":null,"severity":"warning","filePath":"framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ModuleManager.cs","lineNumber":88,"sourceCode":"\n        _logger.LogInformation(\"Initialized all ABP modules.\");\n    }\n\n    public virtual async Task ShutdownModulesAsync(ApplicationShutdownContext context)\n    {\n        var modules = _moduleContainer.Modules.Reverse().ToList();\n\n        foreach (var contributor in _lifecycleContributors)\n        {\n            foreach (var module in modules)\n            {\n                try\n                {\n                    await contributor.ShutdownAsync(context, module.Instance);\n                }\n                catch (Exception ex)\n                {\n                    throw new AbpShutdownException($\"An error occurred during the shutdown {contributor.GetType().FullName} phase of the module {module.Type.AssemblyQualifiedName}: {ex.Message}. See the inner exception for details.\", ex);\n                }\n            }\n        }\n    }\n\n    public void ShutdownModules(ApplicationShutdownContext context)\n    {\n        var modules = _moduleContainer.Modules.Reverse().ToList();\n\n        foreach (var contributor in _lifecycleContributors)\n        {\n            foreach (var module in modules)\n            {\n                try\n                {\n                    contributor.Shutdown(context, module.Instance);\n                }\n                catch (Exception ex)","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ModuleManager.cs#L70-L106","documentation":"Thrown by ModuleManager.ShutdownModulesAsync when contributor.ShutdownAsync throws while shutting down a module (modules are shut down in reverse order). It is wrapped as AbpShutdownException with the original as InnerException. It signals a failure during the async shutdown phase.","triggerScenarios":"Any exception raised inside contributor.ShutdownAsync(ctx, module.Instance) during async application shutdown (e.g. OnApplicationShutdownAsync throwing).","commonSituations":"A module's OnApplicationShutdownAsync fails flushing/disposing a resource (DB, message bus, file handle), a graceful-disconnect to a broker times out, or a background service throws on stop.","solutions":["Inspect the InnerException for the real cause and fix that disposal/shutdown code.","Make shutdown logic idempotent and defensive — wrap each resource disposal in its own try/catch so one failure does not abort the rest.","Ensure resources being shut down were actually initialized (guard against shutting down a partially-initialized module).","Add cancellation handling so shutdown respects the host token instead of throwing."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// No pre-check; ensure each module's shutdown logic is guarded internally.\n// In OnApplicationShutdownAsync, wrap each resource disposal individually.","typeGuard":null,"tryCatchPattern":"try { await moduleManager.ShutdownModulesAsync(context); }\ncatch (AbpShutdownException ex)\n{\n    logger.LogError(ex.InnerException ?? ex, \"Module shutdown failed: {Msg}\", ex.Message);\n    // continue shutdown of remaining resources\n}","preventionTips":["Never throw from Dispose/shutdown paths.","Make shutdown idempotent and cancellation-aware.","Dispose each resource in its own try/catch so one failure does not cascade."],"tags":["modularity","shutdown","lifecycle","disposal","abp-core"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}