Skip to content

Conversation

@DanTup
Copy link
Contributor

@DanTup DanTup commented Jul 29, 2024

The current insiders version of VS Code includes a new version of NodeJS that fails to spawn .bat files when shell: true is not set:

https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2

It is important to note that there has been a breaking change for Windows users who utilize child_process.spawn and child_process.spawnSync. Node.js will now error with EINVAL if a .bat or .cmd file is passed to child_process.spawn and child_process.spawnSync without the shell option set.

The DebugAdapterExecutable class does not currently allow extensions to set shell: true when describing how their debug adapter should be launched. This PR adds support for passing shell? string | boolean through.

Without this fix, the Flutter debug adapter does not launch (it gets an EINVAL error). With this fix, it launches successfully.

Fixes #224184

I don't know if there's a way to add automated tests for this, so if that is required please provide pointers. Thanks!

DanTup added a commit to Dart-Code/Dart-Code that referenced this pull request Jul 30, 2024
VS Code v1.92 will ship with a breaking change (from a new version of NodeJS) that prevents spawning `.bat` files without using `shell: true`. Although Dart-Code uses `shell: true`, the debug adapter is spawned by VS Code and we don't currently have the ability to ask it to use a shell, which means launching the Flutter debugger on Windows is broken.

I've filed microsoft/vscode#224184 and open a PR at microsoft/vscode#224204 but this will not be included in the 1.92 release, so to keep debugging working on Windows, we need a workaround.

This change switches from asking VS Code to run `flutter.bat debug_adapter` to instead running `dart.exe` and using the same args that Flutter would use. This unfortunately bypasses some code (like ensuring everything is up-to-date), however since we'll have already started things like `flutter daemon` at the start of the session, it's very unlikely everything won't already be set up.

Once a better fix is available in VS Code, we should use that and change the scope of the `isUnableToRunBatDebugAdapters` VS Code capability to _only_ the version(s) that require this workaround, because it makes assumptions about flags passed to `dart` that may or may not remain accurate across Flutter SDK versions.

Fixes #5183
DanTup added a commit to Dart-Code/Dart-Code that referenced this pull request Jul 30, 2024
VS Code v1.92 will ship with a breaking change (from a new version of NodeJS) that prevents spawning `.bat` files without using `shell: true`. Although Dart-Code uses `shell: true`, the debug adapter is spawned by VS Code and we don't currently have the ability to ask it to use a shell, which means launching the Flutter debugger on Windows is broken.

I've filed microsoft/vscode#224184 and open a PR at microsoft/vscode#224204 but this will not be included in the 1.92 release, so to keep debugging working on Windows, we need a workaround.

This change switches from asking VS Code to run `flutter.bat debug_adapter` to instead running `dart.exe` and using the same args that Flutter would use. This unfortunately bypasses some code (like ensuring everything is up-to-date), however since we'll have already started things like `flutter daemon` at the start of the session, it's very unlikely everything won't already be set up.

Once a better fix is available in VS Code, we should use that and change the scope of the `isUnableToRunBatDebugAdapters` VS Code capability to _only_ the version(s) that require this workaround, because it makes assumptions about flags passed to `dart` that may or may not remain accurate across Flutter SDK versions.

Fixes #5183
DanTup added a commit to Dart-Code/Dart-Code that referenced this pull request Jul 30, 2024
VS Code v1.92 will ship with a breaking change (from a new version of NodeJS) that prevents spawning `.bat` files without using `shell: true`. Although Dart-Code uses `shell: true`, the debug adapter is spawned by VS Code and we don't currently have the ability to ask it to use a shell, which means launching the Flutter debugger on Windows is broken.

I've filed microsoft/vscode#224184 and open a PR at microsoft/vscode#224204 but this will not be included in the 1.92 release, so to keep debugging working on Windows, we need a workaround.

This change switches from asking VS Code to run `flutter.bat debug_adapter` to instead running `dart.exe` and using the same args that Flutter would use. This unfortunately bypasses some code (like ensuring everything is up-to-date), however since we'll have already started things like `flutter daemon` at the start of the session, it's very unlikely everything won't already be set up.

Once a better fix is available in VS Code, we should use that and change the scope of the `isUnableToRunBatDebugAdapters` VS Code capability to _only_ the version(s) that require this workaround, because it makes assumptions about flags passed to `dart` that may or may not remain accurate across Flutter SDK versions.

Fixes #5183
DanTup added a commit to Dart-Code/Dart-Code that referenced this pull request Jul 30, 2024
VS Code v1.92 will ship with a breaking change (from a new version of NodeJS) that prevents spawning `.bat` files without using `shell: true`. Although Dart-Code uses `shell: true`, the debug adapter is spawned by VS Code and we don't currently have the ability to ask it to use a shell, which means launching the Flutter debugger on Windows is broken.

I've filed microsoft/vscode#224184 and open a PR at microsoft/vscode#224204 but this will not be included in the 1.92 release, so to keep debugging working on Windows, we need a workaround.

This change switches from asking VS Code to run `flutter.bat debug_adapter` to instead running `dart.exe` and using the same args that Flutter would use. This unfortunately bypasses some code (like ensuring everything is up-to-date), however since we'll have already started things like `flutter daemon` at the start of the session, it's very unlikely everything won't already be set up.

Once a better fix is available in VS Code, we should use that and change the scope of the `isUnableToRunBatDebugAdapters` VS Code capability to _only_ the version(s) that require this workaround, because it makes assumptions about flags passed to `dart` that may or may not remain accurate across Flutter SDK versions.

Fixes #5183
DanTup added a commit to Dart-Code/Dart-Code that referenced this pull request Jul 30, 2024
VS Code v1.92 will ship with a breaking change (from a new version of NodeJS) that prevents spawning `.bat` files without using `shell: true`. Although Dart-Code uses `shell: true`, the debug adapter is spawned by VS Code and we don't currently have the ability to ask it to use a shell, which means launching the Flutter debugger on Windows is broken.

I've filed microsoft/vscode#224184 and open a PR at microsoft/vscode#224204 but this will not be included in the 1.92 release, so to keep debugging working on Windows, we need a workaround.

This change switches from asking VS Code to run `flutter.bat debug_adapter` to instead running `dart.exe` and using the same args that Flutter would use. This unfortunately bypasses some code (like ensuring everything is up-to-date), however since we'll have already started things like `flutter daemon` at the start of the session, it's very unlikely everything won't already be set up.

Once a better fix is available in VS Code, we should use that and change the scope of the `isUnableToRunBatDebugAdapters` VS Code capability to _only_ the version(s) that require this workaround, because it makes assumptions about flags passed to `dart` that may or may not remain accurate across Flutter SDK versions.

Fixes #5183
@DanTup
Copy link
Contributor Author

DanTup commented Jul 30, 2024

This is being fixed better by #224320

@DanTup DanTup closed this Jul 30, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Sep 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DebugAdapterExecutable does not support passing shell: true so .bat-based debug adapters are broken in current Insiders

2 participants