Skip to content

[messaging] feat: fix multiple error message handler - #42

Merged
Sebastian-Iwanczyszyn merged 1 commit into
mainfrom
feat/multiple-error-handler
Mar 31, 2026
Merged

[messaging] feat: fix multiple error message handler#42
Sebastian-Iwanczyszyn merged 1 commit into
mainfrom
feat/multiple-error-handler

Conversation

@Sebastian-Iwanczyszyn

Copy link
Copy Markdown
Contributor

Motivation

Fixes error handling in HandlerMiddleware when multiple handlers are registered for the same routing key and one of them fails asynchronously.

Previously, the single-handler path wrapped errors correctly, but the multi-handler path assumed every rejected result from Promise.allSettled() had the shape { handler, error }. That was only true for synchronous throws caught inside the
mapper. For normal async rejections, result.reason was the raw Error, which caused follow-up handling to read undefined and break error logging/aggregation.

What Changed

  • Normalized multi-handler execution so both sync throws and async rejections are wrapped consistently with handler metadata
  • Preserved existing behavior for successful handlers and aggregated HandlersException
  • Added a unit test covering the case where multiple handlers are registered and one rejects

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Code improvement / refactoring
  • Other (please describe)

Breaking change

  • Yes
  • No

Checklist

  • Unit tests added/updated
  • E2E tests added/updated (if applicable)
  • Documentation updated if needed

@Sebastian-Iwanczyszyn
Sebastian-Iwanczyszyn merged commit 9e7c0c3 into main Mar 31, 2026
4 checks passed
@Sebastian-Iwanczyszyn
Sebastian-Iwanczyszyn deleted the feat/multiple-error-handler branch March 31, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant