Skip to content

Futures API should check callback function types synchronously #35812

Open
@zanderso

Description

@zanderso

When the type of an error callback passed to the Futures API is incorrect, the error is flagged asynchronously, which obscures the location of the callback that had the wrong type, e.g.:

[1369.151] 425084.425899> [ERROR:third_party/flutter/shell/common/shell.cc(178)] Dart Error: Unhandled exception:
[1369.151] 425084.425899> type '(Error, StackTrace) => Null' is not a subtype of type '(Object) => dynamic'
[1369.151] 425084.425899> #0      _FutureListener.handleError (dart:async/future_impl.dart:144:46)
[1369.151] 425084.425899> #1      Future._propagateToListeners.handleError (dart:async/future_impl.dart:651:47)
[1369.151] 425084.425899> #2      Future._propagateToListeners (dart:async/future_impl.dart:672:24)
[1369.151] 425084.425899> #3      Future._completeError (dart:async/future_impl.dart:491:5)
[1369.151] 425084.425899> #4      Future.wait.<anonymous closure> (dart:async/future.dart:410:22)
[1369.151] 425084.425899> #5      _RootZone.runUnary (dart:async/zone.dart:1379:54)
[1369.151] 425084.425899> #6      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
[1369.151] 425084.425899> #7      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
[1369.151] 425084.425899> #8      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
[1369.151] 425084.425899> #9      Future._complete (dart:async/future_impl.dart:473:7)
[1369.151] 425084.425899> #10     _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
[1369.151] 425084.425899> #11     _AsyncAwaitCompleter.complete.<anonymous closure> (dart:async/runtime/libasync_patch.dart:33:20)
[1369.151] 425084.425899> #12     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
[1369.151] 425084.425899> #13     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

Either the Futures API should check the callback types synchronously, or the analyzer should detect this problem statically.

Fuchsia issue number is FL-173.

/cc @lrhn @leafpetersen @bwilkerson @alexmarkov

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.customer-fuchsiatype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions