-
Notifications
You must be signed in to change notification settings - Fork 31
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
RollbarFlutter.run is limiting (and probably not working as intended) #90
Comments
Hey @rfuerst87, I appreciate that you shared your concerns in a very detailed manner. I'll talk to the dev team about your comments. |
Any updates here ? , as this become more and more serious since i moved to use 3.10 flutter sdk , it throws random errors and not stable |
@rfuerst87 is there any work around here ? |
Hey @mazen930, Thanks for reporting this issue. Can you share what errors Flutter throws? Do you use the latest Rollbar Flutter SDK (v1.3.0)? |
The following assertion was thrown during runApp: The Flutter bindings were initialized in a different zone than is now being used. This will likely cause confusion and bugs as any zone-specific configuration will inconsistently use the configuration of the original binding initialization zone or this zone based on hard-to-predict factors such as which zone was active when a particular callback was set. |
The 3.10 version of the SDK restricts the call of ensureInitialized, which must be called after runApp to ensure that it runs in the same Zone as the app. In the code of rollbar, the ensureInitialized method is called before runApp |
Got it, thanks for the clarification. Let me take this back to the developers. |
I can reproduce, trying to find a solution. @mrchenmo There's no need to ensure bindings are initialized after
The idea behind calling The problem is that we have two code paths for when users disable error capturing (which doesn't create a Zone in which to run Rollbar), and the normal mode (with error capturing) where we do create a zone. I believe I was able to fix it. Will post a PR soon and link it here. |
With regards to @rfuerst87, I know it's been quite a few months, but I believe your changes to be worth implementing. I wouldn't want to break userspace if someone decides to upgrade from 1.3.0 to 1.4.0, so I'd approach this as providing an alternative (more advanced) way of initializing Rollbar Flutter, together with the usual, simple one. What do you think? If you've already forgotten about this, no problem, I will implement your suggestions one way or another. |
I guess it's important to mention that starting from Flutter 3.3 you souldn't use See What's new in Flutter 3.3 and Handling Errors in Flutter docs . |
I made this into a new issue @ #101, I appreciate the advice! |
@mazen930 @mrchenmo The update with the bug fix (1.3.1) is now published @ https://pub.dev/packages/rollbar_flutter. |
@rollbar-bborsits the error is as @mrchenmo mention above |
@matux unfortunately it didn't work (same error exist) , do i need to edit anything rather than just update ? |
@mazen930 no, you shouldn't have to make any changes. Could you confirm you have the latest version 1.3.1? The SDK example used to crash with this error and is working fine now, so I suspect you might not be using the latest. |
I can ensure that it's latest update :C |
Any update on this? |
The current design of RollbarFlutter makes it impossible to integrate it with custom error handlers. Especially
FlutterRollbar.run
is very limiting. IMHO it has several issues:RollbarFlutter
overwritesFlutterError.onError
without any warnings. Having a customonError
function is not compatible withRollbarFlutter
.RollbarFlutter
incompatible with any other error handler.RollbarFlutter
is creating it's own guarded zone without the possibility to bubble up errors.FlutterRollbar
swallows all the errors without giving other error handlers a chance to catch an error.WidgetsFlutterBinding.ensureInitialized()
is called in the wrong place. When initializing a guarded zoneWidgetsFlutterBinding.ensureInitialized()
must be called within that zone. Calling it outside (as it is done inrun
) causes the guarded zone to not catch errors. At this point I think catching async errors does not properly work. Said that, with the current design one has to ensureWidgetsFlutterBinding.ensureInitialized()
is not called manually before runningRollbarFlutter.run
.In my eyes the design of
RollbarFlutter.run
is flawed. While the intention to make it as easy to integrate as possible is good, but it also bears the downside of inflexibility. InsteadRollbarFlutter
should expose an API to initialize Rollbar and let the user decide how to implement. Something like this could work for example:For convenience one could provide simple helper methods in
RollbarFlutter
to make this an one-liner again. I'm not sure whether this is needed to be honest.Please let me know what you think. I'd offer my support here to come up with an improved version. We are currently forced to work with a fork which I'd get rid of better sooner than later.
The text was updated successfully, but these errors were encountered: