Skip to content

Cannot return with NULL from Isolate: Exception: Isolate exited without result or error #63590

@botond-kopacz

Description

@botond-kopacz

The following pull request introduced an issue with isolates:
#59666

Steps to Reproduce

  1. Create a method that should be run by the isolate (my example uses http package to download web requests using isolates), which returns null value
  2. Call the isolate function using compute()
  3. An exception is being thrown by the engine (see below)

Expected results:
I can pass null values from functions run via Isolates. Before this pull request it was working as expected.

Actual results:
I receive an engine exception when returning nulls.

Exception details

E/flutter (12100): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: 'package:flutter/src/foundation/_isolates_io.dart': Failed assertion: line 55 pos 12: 'resultData is R': is not true.
E/flutter (12100): #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
E/flutter (12100): #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
E/flutter (12100): #2      compute.<anonymous closure> (package:flutter/src/foundation/_isolates_io.dart:55:12)
E/flutter (12100): #3      _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (12100): #4      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (12100): #5      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (12100): #6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter (12100): #7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
E/flutter (12100): #8      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:808:19)
E/flutter (12100): #9      _StreamController._add (dart:async/stream_controller.dart:682:7)
E/flutter (12100): #10     _StreamController.add (dart:async/stream_controller.dart:624:5)
E/flutter (12100): #11     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter (12100): 
I/flutter (12100): 2020-08-12 10:34:59.877287 PD.runMainInit: Completed
I/flutter (12100): 2020-08-12 10:34:59.877803 PD.runMainInit: Completed, setting state
I/flutter (12100): 2020-08-12 10:35:00.756946 Error occured during WebDownloader.getHtml
I/flutter (12100): 2020-08-12 10:35:00.757186 Url:https://test-url.com
I/flutter (12100): Exception: Isolate exited without result or error.

Flutter doctor

[✓] Flutter (Channel stable, 1.20.1, on Mac OS X 10.15.5 19F101, locale en-US)
    • Flutter version 1.20.1 at /Users/bkopacz/FlutterDev/flutter
    • Framework revision 2ae34518b8 (7 days ago), 2020-08-05 19:53:19 -0700
    • Engine revision c8e3b94853
    • Dart version 2.9.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/bkopacz/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.6, Build version 11E708
    • CocoaPods version 1.9.0

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 47.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (1 available)
    • VOG L29 (mobile) • DUM7N19327008485 • android-arm64 • Android 10 (API 29)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions