Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid rescuing from errors in Active Record transaction callbacks in versions of Rails where they will be re-raised #717

Merged
merged 5 commits into from
Jan 13, 2022

Conversation

imjoehaines
Copy link
Contributor

Goal

Rails used to swallow errors in transaction callbacks like after_commit. In Rails 4.2, the raise_in_transactional_callbacks option was added, which make Rails re-raise errors in these callbacks. The option was removed in Rails 5 and from then on Rails will always re-raise errors in transaction callbacks

We have an Active Record integration that rescues errors in transaction callbacks and sends them to Bugsnag. This is unnecessary on Rails 5+ & 4.2 with raise_in_transactional_callbacks enabled and can cause errors to be reported twice on these versions

This PR is #709 with the config option renamed to raise_in_transactional_callbacks as that's what was eventually released in Rails 4.2 (it went through several refactors/renames across a few PRs). I've also added tests that raise errors in an after_commit callback, so we have coverage of:

  • Rails 3
  • Rails 4 with raise_in_transactional_callbacks enabled
  • Rails 4 with raise_in_transactional_callbacks disabled
  • Rails 5
  • Rails 6

@imjoehaines imjoehaines merged commit efe48cc into next Jan 13, 2022
@imjoehaines imjoehaines deleted the active-record-integration branch January 13, 2022 15:32
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.

3 participants