-
Notifications
You must be signed in to change notification settings - Fork 641
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
refinement doesn't run type checks in production 😱 #1962
Comments
Commit and code linked below makes me presume this is working as intended, and has been this way since v3.0.1. Which, okay, but there's no mention of it in the docs for ... that said I can only imagine 'fixing the bug' could cause big trouble for existing code bases, since any ... but I also wonder how many unknown bugs are out there because lack of throw in production. In this case a bug would only surface if you later tried to do something with a First appeared in v3.0.1: 931976f, and now implemented as: mobx-state-tree/packages/mobx-state-tree/src/utils.ts Lines 407 to 420 in 4a6a9a5
|
This recently affected my codebase as well. We had API data that changed and violated the types. In development, we saw errors being thrown. But we did not see errors in prod. It's a nice reversal of "it works on my machine". Our users' environment was somewhat more resilient (although it introduced subtle errors with regard to missing data). The big problem for us was that we thought we broke something in a commit that happened after the most recent production deploy, when the issue was in an external dependency (a breaking change in API response). Spent a lot of time looking for regressions in unrelated MRs. Overall, I agree that it's a problem to change semantics based on the environment. I also imagine changing that behavior would be dangerous and require a major version bump. I feel like I read somewhere that this is a performance concern - it's expensive to do runtime type checking. Perhaps there's an option to run MST in "strict" mode, which would funnily behave like development mode. If there's interest from the maintainers at exploring solutions, I'd be happy to contribute some time and effort here. |
Another idea that comes to mind: never throw errors, not even in development. But in development, emit warnings or logs about issues. That way, teams wouldn't write error-handling logic and be surprised when exceptions stop getting thrown in production. The development environment would be noisier, but the behavior would stay consistent. |
It's been a while since this issue has seen movement, but I'm of the opinion that this is worth exploring. I'm going to leave it as an issue for now, but I'm open to:
|
Bug report
Sandbox link or minimal reproduction code
Describe the expected behavior
Crash with unhandled exception:
because I modified
Todo.js
to be:Describe the observed behavior
It doesn't crash.
Note that if you delete the
.env
file I added (putting it back in to development mode) the exception is raised.The text was updated successfully, but these errors were encountered: