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

Errors thrown in autoruns are caught by mobx, errors thrown in reactions are not caught #1480

Closed
6 tasks done
philipstanislaus opened this issue Apr 6, 2018 · 3 comments
Closed
6 tasks done

Comments

@philipstanislaus
Copy link

philipstanislaus commented Apr 6, 2018

Expected behavior

Errors thrown from reactions and autoruns are both caught, onReactionError handler is called for both.

Actual behavior

Errors thrown from reactions are not caught, onReactionError handler is not called.

Reproduction example

https://codesandbox.io/s/xr2nzz41zq

Steps to reproduce

  1. Click on "Throw error in autorun", go to console => error is caught, onReactionError handler logs to console.
  2. Click on "Throw error in reaction" => error is not caught, application crashes, onReactionError handler is not called.

Versions

mobx 4.1.0, mobx-react 5.0.0, react 16.0.0, react-dom 16.0.0

Template

  1. Issue:
  • Provide error messages including stacktrace
  • Provide a minimal sample reproduction. Create a reproduction based on this sandbox
  • Did you check this issue wasn't filed before?
  • Elaborate on your issue. What behavior did you expect?
  • State the versions of MobX and relevant libraries. Which browser / node / ... version?
@urugator
Copy link
Collaborator

urugator commented Apr 7, 2018

Note it catches errors thrown in "tracking" part (first arg), but not in "effect" part (second arg). Dunno if it's intention or oversight.

@mweststrate
Copy link
Member

Released a fix in 4.2.0

@philipstanislaus
Copy link
Author

Thanks!

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

No branches or pull requests

3 participants