Skip to content

flutter run (when spawned from external script) crashes when its stdin is written to #51872

Closed

Description

@smokytheangel0

Steps to Reproduce

description: I was attempting to induce a hot reload from a build/test script written in rust,
this example illustrates the attempted use of q hotkey after flutter is running

  1. install rust toolchain (https://www.rust-lang.org/tools/install)
  2. cargo new flutter_stdin
  3. paste https://gist.github.com/smokytheangel0/c2f4b97ab0037a1e1357b9848dd17274 into flutter_stdin/src/main.rs
  4. cargo build in flutter_stdin
  5. flutter create stdin_test in ../
  6. cp flutter_stdin/target/debug/flutter_stdin stdin_test
  7. ./flutter_stdin in stdin_test

Logs

Unhandled exception:
FileSystemException: writeFrom failed, path = '' (OS Error: Broken pipe, errno = 32)
#0      _RandomAccessFile.writeFromSync (dart:io/file_impl.dart:881:7)
#1      _StdConsumer.addStream.<anonymous closure> (dart:io/stdio.dart:312:15)
#2      _rootRunUnary (dart:async/zone.dart:1138:13)
#3      _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#4      _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
#5      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#6      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
#7      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:773:19)
#8      _StreamController._add (dart:async/stream_controller.dart:649:7)
#9      _StreamController.add (dart:async/stream_controller.dart:595:5)
#10     _StreamSinkImpl.add (dart:io/io_sink.dart:158:17)
#11     _IOSinkImpl.write (dart:io/io_sink.dart:291:5)
#12     _StdSink.write (dart:io/stdio.dart:341:11)
#13     Stdio._stdioWrite.<anonymous closure> (package:flutter_tools/src/base/io.dart:276:12)
#14     asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:32)
#15     _rootRun (dart:async/zone.dart:1126:13)
#16     _CustomZone.run (dart:async/zone.dart:1023:19)
#17     _runZoned (dart:async/zone.dart:1518:10)
#18     runZoned (dart:async/zone.dart:1502:12)
#19     asyncGuard (package:flutter_tools/src/base/async_guard.dart:109:3)
#20     Stdio._stdioWrite (package:flutter_tools/src/base/io.dart:275:5)
#21     Stdio.stdoutWrite (package:flutter_tools/src/base/io.dart:269:9)
#22     StdoutLogger.writeToStdOut (package:flutter_tools/src/base/logger.dart:270:48)
#23     StdoutLogger.printStatus (package:flutter_tools/src/base/logger.dart:265:5)
#24     printStatus (package:flutter_tools/src/globals.dart:128:10)
#25     TerminalHandler._commonTerminalInputHandler (package:flutter_tools/src/resident_runner.dart:1161:5)
#26     TerminalHandler.processTerminalInput (package:flutter_tools/src/resident_runner.dart:1303:13)
#27     _rootRunUnary (dart:async/zone.dart:1134:38)
#28     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#29     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
#30     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#31     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
#32     _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:377:20)
#33     _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:252:5)
#34     _AsBroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:476:11)
#35     _rootRunUnary (dart:async/zone.dart:1134:38)
#36     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#37     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
#38     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#39     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
#40     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:70:11)
#41     _EventSinkWrapper.add (dart:async/stream_transformers.dart:17:11)
#42     _StringAdapterSink.add (dart:convert/string_conversion.dart:238:11)
#43     _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:243:7)
#44     _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:314:20)
#45     _ErrorHandlingAsciiDecoderSink.addSlice (dart:convert/ascii.dart:254:17)
#46     _ErrorHandlingAsciiDecoderSink.add (dart:convert/ascii.dart:240:5)
#47     _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:74:18)
#48     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:122:24)
#49     _rootRunUnary (dart:async/zone.dart:1134:38)
#50     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#51     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
#52     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#53     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
#54     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:773:19)
#55     _StreamController._add (dart:async/stream_controller.dart:649:7)
#56     _StreamController.add (dart:async/stream_controller.dart:595:5)
#57     _Socket._onData (dart:io-patch/socket_patch.dart:1878:41)
#58     _rootRunUnary (dart:async/zone.dart:1138:13)
#59     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#60     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
#61     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#62     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
#63     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:773:19)
#64     _StreamController._add (dart:async/stream_controller.dart:649:7)
#65     _StreamController.add (dart:async/stream_controller.dart:595:5)
#66     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1423:33)
#67     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:927:14)
#68     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#69     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#70     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#71     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)

[✓] Flutter (Channel master, v1.15.4-pre.201, on Linux, locale en_US.UTF-8)
    • Flutter version 1.15.4-pre.201 at /home/j0/flutter
    • Framework revision 52a5311924 (5 days ago), 2020-02-27 10:41:08 -0800
    • Engine revision 060a7733a6
    • Dart version 2.8.0 (build 2.8.0-dev.10.0 4189237330)

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /home/j0/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling
      support)
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = /home/j0/Android/Sdk
    • Java binary at: /home/j0/Downloads/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)
    ✗ Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit
      https://flutter.dev/setup/#android-setup for detailed instructions.

[!] Android Studio (version 3.6)
    • Android Studio at /home/j0/Downloads/android-studio
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.41.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.8.1

[✓] Connected device (1 available)
    • Nexus 6P • 84B7N15A07006474 • android-arm64 • Android 8.1.0 (API 27)

! Doctor found issues in 2 categories.

Activity

  1. smokytheangel0 commented on Mar 3, 2020

    @smokytheangel0
    Author

    this code which never writes to stdin does not produce an error, but obviously it also does not perform as intended: https://gist.github.com/smokytheangel0/96edd82a5ced3ac25703609538ee1464

  2. TahaTesser commented on Mar 4, 2020

    @TahaTesser
    Contributor

    Hi @smokytheangel0
    This platform is not meant for assistance on personal code. Please see https://flutter.dev/community for resources and asking questions like this, you may also get some help if you post it on Stack Overflow. Closing, as this isn't an issue with Flutter itself,
    if you disagree please write in the comments and I will reopen it
    Thank you

  3. smokytheangel0 commented on Mar 4, 2020

    @smokytheangel0
    Author

    This was not a post for assistance, I am under the impression that there is a bug in how the flutter tool deals with stdin, the rust code is only there to provide the minimum code to demonstrate the bug. I suppose you could reproduce the bug in other languages, the task was to operate the hot loaded key commands like 'r' for hot reload, 'q' for quit, etc, from a program that is piped to the stdin of the flutter tool.

  4. smokytheangel0 commented on Mar 4, 2020

    @smokytheangel0
    Author

    my build system would very much benefit from being able to operate the flutter run interface through stdin, or a c binding, but I am blocked by this bug.

  5. TahaTesser commented on Mar 5, 2020

    @TahaTesser
    Contributor

    Hi @smokytheangel0

    If you believe there is an issue with Flutter itself
    To better address the issue, would be helpful
    if you could post a minimal code sample to reproduce the problem without the 3rd party code/sdk

    Thank you

  6. added
    in triagePresently being triaged by the triage team
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 5, 2020
  7. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    and removed
    in triagePresently being triaged by the triage team
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jan 2, 2021
  8. christopherfujino commented on Jan 2, 2021

    @christopherfujino
    Contributor

    I'm also hitting this. I wrote a ruby wrapper around the Flutter tool, using IO.popen and also hit this, without even trying to write to the tool's stdin. For example:

          IO.popen([@path_to_flutter, 'pub', 'get']).close
    

    will result in essentially the same stacktrace as OP.

  9. changed the title [-]flutter run (when spawned from rust script) crashes when its stdin is written to[/-] [+]flutter run (when spawned from external script) crashes when its stdin is written to[/+] on Jan 2, 2021
  10. 9 remaining items

  11. self-assigned this
    on Jun 30, 2025
  12. added
    tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.
    on Jun 30, 2025
  13. added
    ⏳Bot is counting down the days until it unassigns the issue
    on Nov 3, 2025
  14. flutter-triage-bot commented on Nov 3, 2025

    @flutter-triage-bot

    This issue is assigned to @bkonyi but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

  15. flutter-triage-bot commented on Nov 18, 2025

    @flutter-triage-bot

    This issue is assigned to @bkonyi but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

  16. flutter-triage-bot commented on Jan 27, 2026

    @flutter-triage-bot

    This issue was assigned to @bkonyi but has had no status updates in a long time. To remove any ambiguity about whether the issue is being worked on, the assignee was removed.

  17. removed
    ⏳Bot is counting down the days until it unassigns the issue
    on Jan 27, 2026
  18. github-actions commented on Sep 7, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  19. locked as resolved and limited conversation to collaborators on Sep 7, 2026
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 listc: crashStack traces logged to the consolefound in release: 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions