Skip to content

Fix repeated unhandled rejections losing the custom handler - #281

Open
snehaapratap wants to merge 1 commit into
reactphp:3.xfrom
snehaapratap:fix/280-reuse-rejection-handler
Open

snehaapratap wants to merge 1 commit into
reactphp:3.xfrom
snehaapratap:fix/280-reuse-rejection-handler

Conversation

@snehaapratap

Copy link
Copy Markdown

A custom rejection handler is currently removed permanently after its first invocation, so a second unhandled rejection falls back to the default logger. Restore the handler after it returns so subsequent independent rejections use it again.

The handler remains disabled while it runs, preserving the existing guard against recursively invoking it for an unhandled rejection created inside the handler. Extend the existing PHPT tests to cover both repeated independent rejections and repeated outer rejections that each produce a nested rejection.

Fixes #280.

Validation on PHP 8.5.4:

  • Both extended PHPT tests fail before the source change.
  • Full PHPUnit suite: 368 tests, 548 assertions, 2 skipped, no failures.
  • PHPStan max level: no errors.
  • git diff --check passes.

Implemented and tested with AI assistance (OpenAI Codex).

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.

Custom rejection handlers can only be used once

1 participant