patrol icon indicating copy to clipboard operation
patrol copied to clipboard

The develop test run crashes in terminal

Open ibrahimmansour1 opened this issue 1 year ago • 7 comments

Steps to reproduce

when i run develop test from terminal using $ patrol develop --target=integration_test/app_test.dart on simulator "iPhone 16 Pro"

Actual results

it always crashes after about 6 min and i have to restart it a lot the run doesn't stand longer than 400 second and gives me Oops; flutter has exited unexpectedly: "Bad state: Stream has already been listened to.". A crash report has been written to /Users/ibrahim/Documents/almalek_exchange/flutter_28.log

Logs

Logs
Flutter crash report.
Please report a bug at https://github.com/flutter/flutter/issues.

## command

flutter attach --no-version-check --suppress-analytics --debug --device-id F93CD49E-7549-48E9-B0DF-0799A5A37941 --app-id com.example.almalekExchange --target /Users/ibrahim/Documents/almalek_exchange/integration_test/test_bundle.dart --dart-define PATROL_WAIT=0 --dart-define PATROL_APP_PACKAGE_NAME=com.example.almalek_exchange --dart-define PATROL_APP_BUNDLE_ID=com.example.almalekExchange --dart-define PATROL_ANDROID_APP_NAME=Almalek Exchange --dart-define PATROL_IOS_APP_NAME=Almalek Exchange --dart-define INTEGRATION_TEST_SHOULD_REPORT_RESULTS_TO_NATIVE=false --dart-define PATROL_TEST_LABEL_ENABLED=true --dart-define PATROL_HOT_RESTART=true --dart-define PATROL_IOS_INSTALLED_APPS=["com.apple.Bridge","com.apple.DocumentsApp","com.apple.Fitness","com.apple.Health","com.apple.Maps","com.apple.MobileAddressBook","com.apple.MobileSMS","com.apple.Passbook","com.apple.Passwords","com.apple.Preferences","com.apple.PreviewShell","com.apple.mobilecal","com.apple.mobilesafari","com.apple.mobileslideshow","com.apple.news","com.apple.reminders","com.apple.shortcuts","com.apple.webapp","com.example.almalek-exchange.RunnerUITests.xctrunner"] --dart-define PATROL_TEST_SERVER_PORT=8081 --dart-define PATROL_APP_SERVER_PORT=8082

## exception

StateError: Bad state: Stream has already been listened to.

#0 _StreamController._subscribe (dart:async/stream_controller.dart:686:7) #1 _ControllerStream._createSubscription (dart:async/stream_controller.dart:837:19) #2 _StreamImpl.listen (dart:async/stream_impl.dart:497:9) #3 new _ForwardingStreamSubscription (dart:async/stream_pipe.dart:114:10) #4 _ForwardingStream._createSubscription (dart:async/stream_pipe.dart:86:16) #5 _ForwardingStream.listen (dart:async/stream_pipe.dart:81:12) #6 FlutterDevice.connect (package:flutter_tools/src/resident_runner.dart:267:35) #7 ResidentRunner.connectToServiceProtocol (package:flutter_tools/src/resident_runner.dart:1404:21) #8 HotRunner.attach (package:flutter_tools/src/run_hot.dart:236:13) #9 AttachCommand._attachToDevice (package:flutter_tools/src/commands/attach.dart:403:31) #10 AttachCommand.runCommand (package:flutter_tools/src/commands/attach.dart:265:5) #11 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1408:27) #12 AppContext.run. (package:flutter_tools/src/base/context.dart:153:19) #13 CommandRunner.runCommand (package:args/command_runner.dart:212:13) #14 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:420:9) #15 AppContext.run. (package:flutter_tools/src/base/context.dart:153:19) #16 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:364:5) #17 run.. (package:flutter_tools/runner.dart:130:9) #18 AppContext.run. (package:flutter_tools/src/base/context.dart:153:19) #19 main (package:flutter_tools/executable.dart:93:3)


## flutter doctor

[✓] Flutter (Channel stable, 3.24.5, on macOS 15.0.1 24A348 darwin-arm64, locale en-EG) • Flutter version 3.24.5 on channel stable at /Users/ibrahim/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision dec2ee5c1f (6 weeks ago), 2024-11-13 11:13:06 -0800 • Engine revision a18df97ca5 • Dart version 3.5.4 • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) • Android SDK at /Users/ibrahim/Library/Android/sdk • Platform android-35, build-tools 35.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 16B40 • CocoaPods version 1.16.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2024.2) • 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 21.0.3+-79915917-b509.11)

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

[✓] VS Code (version 1.95.3) • VS Code at /Users/ibrahim/Downloads/Visual Studio Code.app/Contents • Flutter extension version 3.102.0

[✓] Connected device (3 available) • iPhone 16 Pro (mobile) • F93CD49E-7549-48E9-B0DF-0799A5A37941 • ios • com.apple.CoreSimulator.SimRuntime.iOS-18-1 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 15.0.1 24A348 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.0.1 24A348 darwin-arm64 ! Error: Browsing on the local area network for FARES. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac. The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources • All expected network resources are available.

! Doctor found issues in 1 category.

Patrol version

patrol: ^3.13.2

Patrol Doctor output

Patrol Doctor output
Patrol doctor:
Patrol CLI version: 3.4.1
Flutter command: flutter 
  Flutter 3.24.5 • channel stable
Android: 
• Program adb found in /opt/homebrew/bin/adb
• Env var $ANDROID_HOME is not set. (See the link: https://developer.android.com/tools/variables#set)
iOS / macOS: 
• Program xcodebuild found in /usr/bin/xcodebuild
• Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller

Flutter Doctor output

Flutter Doctor output
[✓] Flutter (Channel stable, 3.24.5, on macOS 15.0.1 24A348 darwin-arm64, locale en-EG)
    • Flutter version 3.24.5 on channel stable at /Users/ibrahim/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (6 weeks ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/ibrahim/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2024.2)
    • 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 21.0.3+-79915917-b509.11)

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

[✓] VS Code (version 1.95.3)
    • VS Code at /Users/ibrahim/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0
[✓] Connected device (3 available)
    • iPhone 16 Pro (mobile)          • F93CD49E-7549-48E9-B0DF-0799A5A37941 • ios          • com.apple.CoreSimulator.SimRuntime.iOS-18-1 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64 • macOS 15.0.1 24A348 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin       • macOS 15.0.1 24A348 darwin-arm64

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

ibrahimmansour1 avatar Dec 25 '24 04:12 ibrahimmansour1

Same here with all the latest packages at this date. The issue happens usually just after an action with native automator (e.g await $.native.tap(Selector(text: selector)); ) In my case is it not related with test duration as the native action are part of the initial flow of the app (when didomi pops) There does not seem to have logs about the failure in the console....

AurelienKun avatar Dec 31 '24 13:12 AurelienKun

I am experiencing the same issue and have to restart constantly. Is there a solution?

mehmetdogan1180 avatar Jan 03 '25 06:01 mehmetdogan1180

+1

ryanhanks-bestow avatar Jan 13 '25 07:01 ryanhanks-bestow

Appears related to https://github.com/flutter/flutter/issues/156692

ryanhanks-bestow avatar Jan 14 '25 10:01 ryanhanks-bestow

UPD It was a different, unrelated error in my case. Characters in terminal starting from 3.14 should be ASCII, other may shut down terminal Link to discussion : https://github.com/leancodepl/patrol/discussions/2455

EvgenSilkov avatar Jan 17 '25 14:01 EvgenSilkov

I'm experiencing the same every second build

Kurczaak avatar Jan 31 '25 10:01 Kurczaak

Why doesnt patrol notify the user of this? I was one 1.4.2 still, and did the install instructions a couple months ago. Now it requires 1.5.1 according to patrol install doc. But as a longtime user i got no clue i need to manually update this.

ahlstro avatar Feb 27 '25 17:02 ahlstro

seeing this error after doing a fresh installation and following setup guide.

Oops; flutter has exited unexpectedly: "Bad state: Stream has already been listened to."

dishankjindal1 avatar May 24 '25 18:05 dishankjindal1

Hi guys, this problem still appear in the newest patrol and cli versions?

Kendru98 avatar Jul 14 '25 11:07 Kendru98

Looks like duplicate of https://github.com/leancodepl/patrol/issues/1748

Kendru98 avatar Aug 01 '25 12:08 Kendru98

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue.

github-actions[bot] avatar Aug 08 '25 13:08 github-actions[bot]