Skip to content

Exceptions in runZonedExperimental's onDone are handled weirdly #12195

Closed
@alxhub

Description

@alxhub

I expect the following Dart program to crash with an unhandled "Exceptional" Exception.

import "dart:async";

main() {
  runZonedExperimental(() {}, onDone: () {
    throw new Exception("Exceptional");
  });
}

Instead, it crashes on an assertion failure in async/zone.dart:
                                                                                                                                                                                                                                                                                                                                        
Unhandled exception:
'dart:async/zone.dart': Failed assertion: line 115 pos 12: '! _children.isEmpty' is not true.

­0 _ZoneBase._removeChild (dart:async/zone.dart:115:12)

­1 _ZoneBase._dispose (dart:async/zone.dart:48:31)

­2 _WaitForCompletionZone._dispose (dart:async/zone.dart:169:19)

­3 _ZoneBase._checkIfDone (dart:async/zone.dart:53:15)

­4 _ZoneBase._runInZone (dart:async/zone.dart:95:19)

­5 _ZoneBase._runUnguarded (dart:async/zone.dart:102:22)

­6 _WaitForCompletionZone.runWaitForCompletion (dart:async/zone.dart:166:30)

­7 runZonedExperimental (dart:async/zone.dart:262:37)

­8 main (test.dart:4:23)

It seems like onDone is not handling exceptions properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.closed-duplicateClosed in favor of an existing reportlibrary-async

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions