Skip to content

runZoned with zoneValues unavailable during integration_test #96939

Open

Description

@felangel

Steps to Reproduce

  1. Create a basic flutter app which wraps runApp with runZoned and provides a custom zone value:
import 'dart:async';

import 'package:flutter/material.dart';

const zoneKey = Object();

void main() {
  runZoned(
    () => runApp(const MyApp()),
    zoneValues: {zoneKey: 'Hello World'},
  );
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final zoneValue = Zone.current[zoneKey];
    print('MyApp.build() $zoneValue'); // NULL during integration_test run
    return const MaterialApp();
  }
}
  1. Write an integration test:
import 'package:flutter_test/flutter_test.dart';
import 'package:example/main.dart' as app;

void main() {
  group('App', () {
    testWidgets('renders MyApp', (tester) async {
      app.main();
      await tester.pumpAndSettle();
      expect(find.byType(app.MyApp), findsOneWidget);
    });
  });
}
  1. Run the integration test flutter test integration_test
  2. Observe that the zone value is null within the build method of MyApp

Expected results:

I'd expect the zone value to be available within the build method since runApp was executed within the zone.

Actual results:

The zone value is null within the build method during the integration_test run.

Additional Context

Even when the entire test suite is wrapped in runZoned, the zone values are not available during an integration_test run:

void main() {
  runZoned(() {
    final zoneValue = Zone.current[app.zoneKey];
    print('test.main(), $zoneValue'); // Hello Test
    group('App', () {
      final zoneValue = Zone.current[app.zoneKey];
      print('test.group(), $zoneValue'); // Hello Test
      testWidgets('renders MyApp', (tester) async {
        final zoneValue = Zone.current[app.zoneKey];
        print('test.testWidgets(), $zoneValue'); // null
        app.main();
        await tester.pumpAndSettle();
        expect(find.byType(app.MyApp), findsOneWidget);
      });
    });
  }, zoneValues: {app.zoneKey: 'Hello Test'});
}

It looks like testWidgets runs the body inside a new zone and does not fork the parent zone and inherit the zoneValues.

Related Issues

Logs
{"CFBundleName":"zones","DTXcode":"1310","DTSDKName":"iphonesimulator15.0","UILaunchStoryboardName":"LaunchScreen","CFBundleIcons~ipad":{"CFBundlePrimaryIcon":{"CFBundleIconFiles":["AppIcon20x20","AppIcon29x29","AppIcon40x40","AppIcon60x60","AppIcon76x76","AppIcon83.5x83.
5"],"CFBundleIconName":"AppIcon"}},"DTSDKBuild":"19A339","CFBundleDevelopmentRegion":"en","CFBundleVersion":"1","BuildMachineOSBuild":"21A559","DTPlatformName":"iphonesimulator","CFBundlePackageType":"APPL","UIMainStoryboardFile":"Main","CFBundleSupportedPlatforms":["iPho
neSimulator"],"CFBundleShortVersionString":"1.0.0","CFBundleInfoDictionaryVersion":"6.0","CFBundleExecutable":"Runner","DTCompiler":"com.apple.compilers.llvm.clang.1_0","UISupportedInterfaceOrientations~ipad":["UIInterfaceOrientationPortrait","UIInterfaceOrientationPortra
itUpsideDown","UIInterfaceOrientationLandscapeLeft","UIInterfaceOrientationLandscapeRight"],"MinimumOSVersion":"9.0","CFBundleIdentifier":"com.example.zones","UIDeviceFamily":[1,2],"DTPlatformVersion":"15.0","CFBundleSignature":"????","CFBundleIcons":{"CFBundlePrimaryIcon
":{"CFBundleIconFiles":["AppIcon20x20","AppIcon29x29","AppIcon40x40","AppIcon60x60"],"CFBundleIconName":"AppIcon"}},"DTXcodeBuild":"13A1030d","LSRequiresIPhoneOS":true,"UISupportedInterfaceOrientations":["UIInterfaceOrientationPortrait","UIInterfaceOrientationLandscapeLef
t","UIInterfaceOrientationLandscapeRight"],"UIViewControllerBasedStatusBarAppearance":false,"NSBonjourServices":["_dartobservatory._tcp"],"DTPlatformBuild":"19A339","NSLocalNetworkUsageDescription":"Allow Flutter tools on your computer to connect and debug your
application. This prompt will not appear on release builds."}
[   +4 ms] executing: xcrun simctl launch FCB4BE3E-33DA-49FC-A861-F647555D56A9 com.example.zones --enable-dart-profiling --enable-checked-mode --verify-entry-points --observatory-port=0
[ +205 ms] com.example.zones: 51465
[   +1 ms] Waiting for observatory port to be available...
[ +416 ms] Observatory URL on device: http://127.0.0.1:55348/QIoVQ24XVz0=/
[   +9 ms] Caching compiled dill
[  +51 ms] Connecting to service protocol: http://127.0.0.1:55348/QIoVQ24XVz0=/
[ +167 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:55348/QIoVQ24XVz0=/.
[  +95 ms] DDS is listening at http://127.0.0.1:55351/1RcuH9jFcOE=/.
[  +59 ms] Successfully connected to service protocol: http://127.0.0.1:55348/QIoVQ24XVz0=/
[  +26 ms] DevFS: Creating new filesystem on the device (null)
[  +17 ms] DevFS: Created new filesystem on the device (file:///Users/felix/Library/Developer/CoreSimulator/Devices/FCB4BE3E-33DA-49FC-A861-F647555D56A9/data/Containers/Data/Application/42BE9414-534D-477C-ADEB-EDC73F58B7FA/tmp/zonesEyB4Fm/zones/)
[   +2 ms] Updating assets
[  +63 ms] Syncing files to device iPhone 13...
[   +2 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[   +3 ms] <- recompile package:zones/main.dart 7fd16ad6-36b9-4ac5-99dd-f42726cef603
[        ] <- 7fd16ad6-36b9-4ac5-99dd-f42726cef603
[  +64 ms] Updating files.
[        ] DevFS: Sync finished
[        ] Syncing files to device iPhone 13... (completed in 71ms)
[        ] Synced 0.0MB.
[   +1 ms] <- accept
[   +6 ms] Connected to _flutterView/0x7fb30a810c20.
[   +3 ms] Flutter run key commands.
[   +1 ms] r Hot reload. 🔥🔥🔥
[        ] R Hot restart.
[        ] h List all available interactive commands.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] 💪 Running with sound null safety 💪
[        ] An Observatory debugger and profiler on iPhone 13 is available at: http://127.0.0.1:55351/1RcuH9jFcOE=/
[ +490 ms] The Flutter DevTools debugger and profiler on iPhone 13 is available at: http://127.0.0.1:9102?uri=http://127.0.0.1:55351/1RcuH9jFcOE=/
[+4486 ms] Skipping target: gen_localizations
[        ] Skipping target: gen_dart_plugin_registrant
[        ] Skipping target: _composite
[        ] complete
[        ] Performing hot reload...
[  +11 ms] Scanned through 528 files in 6ms
[        ] Syncing files to device iPhone 13...
[        ] Compiling dart to kernel with 0 updated files
[        ] <- recompile package:zones/main.dart 564d0ee5-dbd9-4020-bfeb-4217c387483f
[        ] <- 564d0ee5-dbd9-4020-bfeb-4217c387483f
[   +6 ms] Updating files.
[   +2 ms] DevFS: Sync finished
[        ] Syncing files to device iPhone 13... (completed in 9ms)
[        ] Synced 0.0MB.
[  +11 ms] Reassembling application
[  +39 ms] Hot reload performed in 67ms.
[   +1 ms] Performing hot reload... (completed in 73ms)
[        ] Reloaded 0 libraries in 78ms.
No issues found! (ran in 1.9s)
[✓] Flutter (Channel beta, 2.7.0-3.1.pre, on macOS 12.0.1 21A559 darwin-x64, locale en-US)
    • Flutter version 2.7.0-3.1.pre at /Users/felix/fvm/versions/beta
    • Upstream repository [email protected]:flutter/flutter.git
    • Framework revision fc7015e35a (3 weeks ago), 2021-10-27 15:18:41 -0700
    • Engine revision a75e3b80f9
    • Dart version 2.15.0 (build 2.15.0-178.1.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/felix/Library/Android/sdk
    • Platform android-30, 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 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Community Edition (version 2021.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.60.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.27.0

[✓] VS Code (version 1.63.0-insider)
    • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension version 3.28.0

[✓] Connected device (3 available)
    • iPhone 13 (mobile) • FCB4BE3E-33DA-49FC-A861-F647555D56A9 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • macOS (desktop)    • macos                                • darwin-x64     • macOS 12.0.1 21A559 darwin-x64
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 95.0.4638.69

• No issues found!

Activity

  1. danagbemava-nc commented on Jan 21, 2022

    @danagbemava-nc
    Member

    Hi @felangel, you appear to be on an older version of beta.

    Can you upgrade to the latest version to see if you still experience this issue?

    Thank you

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jan 21, 2022
  3. felangel commented on Jan 25, 2022

    @felangel
    ContributorAuthor

    Hey @danagbemava-nc sorry for the delayed response.

    I just verified that I'm seeing the same result on the master channel:

    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel master, 2.9.0-1.0.pre.498, on macOS 12.0.1 21A559 darwin-x64, locale en-US)
    [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    [✓] Xcode - develop for iOS and macOS (Xcode 13.1)
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 4.1)
    [✓] IntelliJ IDEA Community Edition (version 2021.2)
    [✓] VS Code (version 1.63.2)
    [✓] VS Code (version 1.64.0-insider)
    [✓] Connected device (3 available)
        ! Error: Felix’s iPhone is not connected. Xcode will continue when Felix’s iPhone is connected. (code -13)
    [✓] HTTP Host Availability
    
    • No issues found!
    
  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jan 25, 2022
  5. Hixie commented on Jan 25, 2022

    @Hixie
    Contributor

    I suspect the same would happen in a unit test (with flutter_test). The problem is likely that Zone.current is not the zone you are expecting, because integration_test and flutter_test make heavy use of zones of their own. You might be able to find the data by walking up the chain of Zones until you get to the one you expect.

    (In general I personaly would recommend against using Zones, they are a never-ending source of pain in my experience. Better to just inject an InheritedWidget and/or pass the data via arguments.)

  6. felangel commented on Jan 25, 2022

    @felangel
    ContributorAuthor

    I suspect the same would happen in a unit test (with flutter_test). The problem is likely that Zone.current is not the zone you are expecting, because integration_test and flutter_test make heavy use of zones of their own. You might be able to find the data by walking up the chain of Zones until you get to the one you expect.

    Shouldn't integration_test and flutter_test respect the current zone they are in and fork it (preserving the zone values)?

    (In general I personaly would recommend against using Zones, they are a never-ending source of pain in my experience. Better to just inject an InheritedWidget and/or pass the data via arguments.)

    This is not feasible because this is an issue in the context of a pure Dart package being used within a Flutter application. The implementation is pure Dart.

  7. danagbemava-nc commented on Jan 26, 2022

    @danagbemava-nc
    Member

    Reproducible using sample and steps in #96939 (comment).

    code samples

    main.dart

    import 'dart:async';
    
    import 'package:flutter/material.dart';
    
    const zoneKey = Object();
    
    void main() {
      runZoned(
        () => runApp(const MyApp()),
        zoneValues: {zoneKey: 'Hello World'},
      );
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        final zoneValue = Zone.current[zoneKey];
        
        // added to make print output visible
        print(
            '+============================+\nMyApp.build() $zoneValue\n+============================+'); // NULL during integration_test run
        return const MaterialApp();
      }
    }
    

    integration_test/app_test.dart

    import 'package:flutter_test/flutter_test.dart';
    import 'package:it/main.dart' as app;
    
    void main() {
      group('App', () {
        testWidgets('renders MyApp', (tester) async {
          app.main();
          await tester.pumpAndSettle();
          expect(find.byType(app.MyApp), findsOneWidget);
        });
      });
    }
    
    logs

    run_log.txt
    test_log.txt

    flutter doctor -v
    [✓] Flutter (Channel stable, 2.8.1, on macOS 11.6.2 20G314 darwin-arm, locale en-GB)
        • Flutter version 2.8.1 at /Users/nexus/dev/sdks/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 77d935af4d (6 weeks ago), 2021-12-16 08:37:33 -0800
        • Engine revision 890a5fca2e
        • Dart version 2.15.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.0)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2020.3)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    
    [☠] IntelliJ IDEA Community Edition (the doctor check crashed)
        ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues.
        ✗ FormatException: Unexpected extension byte (at offset 5)
        • #0      _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1789:7)
          #1      Utf8Decoder.convert (dart:convert/utf.dart:318:42)
          #2      InputStream.readString (package:archive/src/util/input_stream.dart:207:30)
          #3      new ZipDirectory.read (package:archive/src/zip/zip_directory.dart:40:30)
          #4      ZipDecoder.decodeBuffer (package:archive/src/zip_decoder.dart:19:30)
          #5      ZipDecoder.decodeBytes (package:archive/src/zip_decoder.dart:14:12)
          #6      IntelliJPlugins._findPluginXml (package:flutter_tools/src/intellij/intellij.dart:130:44)
          #7      IntelliJPlugins._readPackageVersion (package:flutter_tools/src/intellij/intellij.dart:141:40)
          #8      IntelliJPlugins.validatePackage (package:flutter_tools/src/intellij/intellij.dart:63:35)
          #9      IntelliJValidator.validate (package:flutter_tools/src/intellij/intellij_validator.dart:103:15)
          #10     asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:32)
          #11     asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:109:18)
          #12     _rootRun (dart:async/zone.dart:1428:13)
          #13     _CustomZone.run (dart:async/zone.dart:1328:19)
          #14     _runZoned (dart:async/zone.dart:1863:10)
          #15     runZonedGuarded (dart:async/zone.dart:1851:12)
          #16     runZoned (dart:async/zone.dart:1782:12)
          #17     asyncGuard (package:flutter_tools/src/base/async_guard.dart:109:3)
          #18     Doctor.startValidatorTasks (package:flutter_tools/src/doctor.dart:197:9)
          #19     Doctor.diagnose (package:flutter_tools/src/doctor.dart:301:47)
          #20     DoctorCommand.runCommand (package:flutter_tools/src/commands/doctor.dart:53:47)
          #21     FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1290:12)
          <asynchronous suspension>
          #22     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1140:27)
          <asynchronous suspension>
          #23     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
          <asynchronous suspension>
          #24     CommandRunner.runCommand (package:args/command_runner.dart:209:13)
          <asynchronous suspension>
          #25     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:288:9)
          <asynchronous suspension>
          #26     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
          <asynchronous suspension>
          #27     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:236:5)
          <asynchronous suspension>
          #28     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
          <asynchronous suspension>
          #29     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
          <asynchronous suspension>
          #30     main (package:flutter_tools/executable.dart:94:3)
          <asynchronous suspension>
    
    
    [✓] VS Code (version 1.63.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.32.0
    
    [✓] Connected device (3 available)
        • iPhone 13 (mobile) • 7515F01A-C1B6-456E-8559-8D2383D3719D • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
        • macOS (desktop)    • macos                                • darwin-arm64   • macOS 11.6.2 20G314 darwin-arm
        • Chrome (web)       • chrome                               • web-javascript • Google Chrome 97.0.4692.99
    
    ! Doctor found issues in 1 category.
    [✓] Flutter (Channel master, 2.9.0-1.0.pre.504, on macOS 11.6.2 20G314 darwin-arm, locale en-GB)
        • Flutter version 2.9.0-1.0.pre.504 at /Users/nexus/dev/sdks/flutters
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 94d9b02deb (3 hours ago), 2022-01-25 22:00:07 -0600
        • Engine revision 54e1f3f4bb
        • Dart version 2.17.0 (build 2.17.0-54.0.dev)
        • DevTools version 2.9.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.0)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2020.3)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.3)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin version 213.5744.122
    
    [✓] VS Code (version 1.63.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.32.0
    
    [✓] Connected device (3 available)
        • iPhone 13 (mobile) • 7515F01A-C1B6-456E-8559-8D2383D3719D • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
        • macOS (desktop)    • macos                                • darwin-arm64   • macOS 11.6.2 20G314 darwin-arm
        • Chrome (web)       • chrome                               • web-javascript • Google Chrome 97.0.4692.99
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
  8. added
    a: tests"flutter test", flutter_test, or one of our tests
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Jan 26, 2022
  9. Hixie commented on Jan 26, 2022

    @Hixie
    Contributor

    I suspect the same would happen in a unit test (with flutter_test). The problem is likely that Zone.current is not the zone you are expecting, because integration_test and flutter_test make heavy use of zones of their own. You might be able to find the data by walking up the chain of Zones until you get to the one you expect.

    Shouldn't integration_test and flutter_test respect the current zone they are in and fork it (preserving the zone values)?

    Hm, as far as I can tell from the code, they do. Weird. Maybe there's somewhere where we fail to do that?

    Might be helpful to walk the zone tree at the place where you're not finding your values, and see what the tree contains and where the values get dropped.

    (In general I personaly would recommend against using Zones, they are a never-ending source of pain in my experience. Better to just inject an InheritedWidget and/or pass the data via arguments.)

    This is not feasible because this is an issue in the context of a pure Dart package being used within a Flutter application. The implementation is pure Dart.

    I mean, you can always use arguments, even in pure Dart. :-)

  10. 51 remaining items

  11. Hixie commented on Jun 21, 2022

    @Hixie
    Contributor

    @bartekpacia I assure you if there was news we would have posted it. :-)
    That said, if you are interested in contributing a fix, I'm sure we would be open to reviewing it. The first step is to figure out exactly what the fix should even be.

  12. removed their assignment
    on Jun 22, 2022
  13. bartekpacia commented on Jul 21, 2022

    @bartekpacia
    Member

    I assure you if there was news we would have posted it. :-)

    I don't doubt this 😁

    That said, if you are interested in contributing a fix, I'm sure we would be open to reviewing it.

    I'd love to, but I'm not familiar with the internals of the framework (and don't have time to dive into it) :(

    Also, this also occurs in Flutter 2.10 and 3.0, so you could update the labels :)

  14. bartekpacia commented on Feb 20, 2023

    @bartekpacia
    Member

    Might be related to dart-lang/test#1023?

  15. flutter-triage-bot commented on Jul 17, 2023

    @flutter-triage-bot

    This issue is marked P1 but has had no recent status updates.

    The P1 label indicates high-priority issues that are at the top of the work list. This is the highest priority level a bug can have if it isn't affecting a top-tier customer or breaking the build. Bugs marked P1 are generally actively being worked on unless the assignee is dealing with a P0 bug (or another P1 bug). Issues at this level should be resolved in a matter of months and should have monthly updates on GitHub.

    Please consider where this bug really falls in our current priorities, and label it or assign it accordingly. This allows people to have a clearer picture of what work is actually planned. Thanks!

  16. added
    P2Important issues not at the top of the work list
    and removed
    P1High-priority issues at the top of the work list
    on Jul 17, 2023
  17. lrhn commented on Feb 14, 2025

    @lrhn
    Contributor

    Drive-by comment, since someone linked to this issue ...

    because integration_test and flutter_test make heavy use of zones of their own.

    That's not necessarily a problem, they should just always create a new zone when used in a new context, and always fork the current zone, not some other zone (like the root zone), to avoid throwing away any existing zone context.

    A new zone can still refer to another older zone, either if that's a transitive parent zone, or they can share a state if they're related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our testsfound in release: 2.10Found to occur in 2.10found in release: 2.8Found to occur in 2.8found in release: 2.9Found to occur in 2.9found in release: 3.0Found to occur in 3.0frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions