Skip to content

Restore the notifier after AS notifications specs#1529

Merged
unflxw merged 1 commit into
mainfrom
restore-notifier-after-as-specs
Jun 26, 2026
Merged

Restore the notifier after AS notifications specs#1529
unflxw merged 1 commit into
mainfrom
restore-notifier-after-as-specs

Conversation

@unflxw

@unflxw unflxw commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

The ActiveSupport::Notifications specs swap in a fresh notifier to control subscriptions but never restore it, leaking a stale, subscription-less notifier into later specs. Running alphabetically the ActionMailer spec ran first and masked it, but in any order where these run first, ActionMailer's instrumentation fired into the stale notifier and recorded nothing. Restore the original notifier in an around hook.

The ActiveSupport::Notifications specs swap in a fresh notifier to
control subscriptions but never restore it, leaking a stale,
subscription-less notifier into later specs. Running alphabetically the
ActionMailer spec ran first and masked it, but in any order where these
run first, ActionMailer's instrumentation fired into the stale notifier
and recorded nothing. Restore the original notifier in an around hook.

[skip changeset]
@backlog-helper

backlog-helper Bot commented Jun 26, 2026

Copy link
Copy Markdown

Hi @unflxw,

We've found some issues with your Pull Request.

  • This Pull Request does not include a changeset. Add a changeset if the change impacts users and should be included in the changelog upon release. Read more about changesets.
    Ignore this rule by adding [skip changeset] to your Pull Request body. - (More info)

New issue guide | Backlog management | Rules | Feedback

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes cross-spec leakage in the ActiveSupport::Notifications hook specs by ensuring any notifier swap performed for test isolation is reverted after each example, preventing later specs (e.g., ActionMailer instrumentation) from publishing into a stale notifier instance.

Changes:

  • Add an around hook that captures the current ActiveSupport::Notifications.notifier before the example runs.
  • Ensure the original notifier is restored in an ensure block after the example (even on failures).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unflxw unflxw added the chore A small task that takes a day or two at the most. label Jun 26, 2026
@unflxw
unflxw merged commit 9ffcdb5 into main Jun 26, 2026
208 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore A small task that takes a day or two at the most.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants