dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.06k stars 1.56k forks source link

stdin stream closes unexpectedly when Dart program is spawned from a bat file (which is spawned by a NodeJS process) and an msys2 program has been run earlier in the bat file #55792

Open DanTup opened 3 months ago

DanTup commented 3 months ago

This might not be a Dart issue, but since changing the Dart script for a NodeJS script seems to cause the issue to go away I wonder if there might at least be someone who might have a better grasp of what's happening here (I feel I've hit the limits of what I can debug).

While the title sounds quite specific, those variables all appear to be required. Some background:

The issue we're seeing is when the version of git the user has on PATH comes from msys2. In this case, when the flutter_tools daemon starts, it gets some input from stdin from the client, but then stdin appears to close and no more input is received. The VS Code extension (NodeJS script) does not see anything change, and continues to send messages over the daemon's stdin but they are never received (and never responded to).

The issue only occurs when:

I've created a repro with some steps here:

https://github.com/DanTup/repro-dart-code-4840

To reproduce, you'll need to be on Windows and have NodeJS and a copy of msys2 (which you can download as a self-extracting archive, it doesn't need installing - you just need to be able to run any of the .exe files from it in the fake_flutter.bat script).

The odd behaviour is almost certainly coming from msys2, but it's odd that when the daemon script is NodeJS this issue doesn't occur. This makes me wonder what Dart is seeing happen that causes it to fire the done handler for stdin (and not get any further input).

Related issues:

mkustermann commented 3 months ago

/cc @brianquinlan

DanTup commented 2 months ago

@brianquinlan please let me know if there's anything I can to help get any more info to help track this down. It's affecting quite a lot of users according to my (admittedly limited) stats so I'm keen to try and fix, but right now I don't have any ideas for either debugging further or trying to workaround/avoid it.