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

fix(callback): Callback given to Sentry are execute safely #2502

Merged
merged 8 commits into from
Sep 29, 2022

Conversation

krystofwoldrich
Copy link
Member

@krystofwoldrich krystofwoldrich commented Sep 28, 2022

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

These callback would crash the whole app if error is not caught.

I've thought about creating one safe() method that could wrap any callback, but for different callback the behaviour changes. Sometimes it makes sense to return undefined, sometimes defaults...

💡 Motivation and Context

Closes: #2499

💚 How did you test it?

Sample app.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • All tests passing
  • No breaking changes

🔮 Next steps

@krystofwoldrich krystofwoldrich marked this pull request as ready for review September 28, 2022 11:40
CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Manoel Aranda Neto <[email protected]>
@marandaneto
Copy link
Contributor

So the safe methods are unit tested but not the functions that use them, if you remove the safeFactory wrapper when setting the before breadcrumb, tests are still green but the behavior is broken, I'd suggest also adding a test for the specific callbacks, just that they don't throw.

Copy link
Contributor

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

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

@krystofwoldrich krystofwoldrich merged commit 260dde8 into main Sep 29, 2022
@krystofwoldrich krystofwoldrich deleted the krystofwoldrich/safeCallbackExecution branch September 29, 2022 08:08
@github-actions
Copy link
Contributor

Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

- Callback given to Sentry are execute safely ([#2502](https://github.com/getsentry/sentry-react-native/pull/2502))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description.

Generated by 🚫 dangerJS against ba8502f

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.

beforeBreadcrumb, withScope callbacks do not have their Exceptions caught
2 participants