Skip to content

Errors are escaping the error zone when thrown from wrapped register* callbacks. #59913

Open
flutter/flutter
#162731
@jakemac53

Description

@jakemac53

See https://dartpad.dev/?id=8d902660cb95b6e9eb87343b6bf1f198

I was playing around with "cancelling" async tasks by running them in zones, and wrapping all registered callbacks with a function that throws an exception if the task has been cancelled. Then I want to catch those specific exceptions and not bubble them up outside the zone. I am sure more needs to happen here to deal with edge cases and timers, but I was hoping this could work as a proof of concept.

However, I am unable to handle the errors thrown inside these callbacks, they don't reach the handleUncaughtError handler in the zone, even though I can see that I am currently running inside the forked zone (and its also the error zone) right before throwing.

Is this intended behavior? Is it not possible to do what I want here?

Metadata

Metadata

Assignees

Labels

area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-asynctype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions