Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron 16 build TS extension opens command prompts on Windows #138792

Closed
rzhao271 opened this issue Dec 9, 2021 · 8 comments
Closed

Electron 16 build TS extension opens command prompts on Windows #138792

rzhao271 opened this issue Dec 9, 2021 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member electron-16-update Issues related to electron 16 update upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-fixed The underlying upstream issue has been fixed verified Verification succeeded windows VS Code on Windows issues
Milestone

Comments

@rzhao271
Copy link
Contributor

rzhao271 commented Dec 9, 2021

With the latest exploration build:

  1. Open VS Code
  2. Open a TS file
  3. 🐛 Command prompts open while the TS extension activates

CPU profile: CPU-20211209T161643.347Z.cpuprofile.txt

@rzhao271 rzhao271 added electron-16-update Issues related to electron 16 update windows VS Code on Windows issues labels Dec 9, 2021
@deepak1556 deepak1556 added this to the January 2022 milestone Dec 16, 2021
@bpasero bpasero added the confirmed Issue has been confirmed by VS Code Team member label Dec 18, 2021
@rzhao271
Copy link
Contributor Author

rzhao271 commented Dec 27, 2021

The only spawning I see the TS extension doing is at

const process = this._factory.fork(version.tsServerPath, args, kind, configuration, this._versionManager);

tsServerPath points to https://github.com/microsoft/TypeScript/blob/main/lib/tsserver.js. There's also https://github.com/microsoft/TypeScript/blob/ef9fd97e4dbcc0a26fa5bac7007e8bfa594ccccd/src/typingsInstaller/nodeTypingsInstaller.ts#L113, but I don't think that is what is causing the npm install types-registry@latest command prompt to pop up.

The extension logs (including verbose server logs) also don't say anything about types-registry or prefix, two packages being installed when the TS extension is activating.

CC @mjbvz

@mjbvz
Copy link
Collaborator

mjbvz commented Jan 3, 2022

TypeScript spawns a 'typing installer' process for automatic type acquisition. This is spawned with a call to .fork here:

https://github.com/microsoft/TypeScript/blob/8590f0db408c419d25ea767783428b59fe6c9d0b/src/tsserver/nodeServer.ts#L510

This process then called execSync to run npm:

https://github.com/microsoft/TypeScript/blob/db01e84700023a4b728fd6e38878264160c43fbf/src/typingsInstaller/nodeTypingsInstaller.ts#L206

@deepak1556
Copy link
Collaborator

Thanks for clarifying the process hierarchy @mjbvz

@rzhao271 the next step here would be to replicate this process tree with a minimal electron app. Basically, we want something like

  • Main Process
    • ELECTRON_RUN_AS_NODE forked child process (Extension host)
      • Fork child process (TsServer)
        • Fork child process (Typing Installer)
          • ExecSync npm.cmd

You can extend the test case at https://gist.github.com/deepak1556/eefed2d47fada30c15ab9077d1532d0b which was used for #137481

@rzhao271
Copy link
Contributor Author

rzhao271 commented Jan 4, 2022

I extended my minimal repro, and I can repro the issue with that process tree after packaging the app. Though, when I launch the unpackaged app from Windows terminal, I notice the title changes to npm version, which is what I made execSync run. Therefore, the unpackaged app also has the problem.

execSync itself causes issues. If I put it in the mock extension host, it still creates npm prefix and npm version command prompts.

Also, to fork the mock TsServer, I noticed that I had to reset execPath to my installed node path, otherwise Electron's node would be used again. Assuming I need to do that execPath reset, I notice another command prompt flash really quickly before the npm command prompts. If we don't have to reset execPath (meaning all children in the process tree use either Electron's node or the standard node), then this issue is irrelevant, but the execSync issue is still there.

@rzhao271 rzhao271 added the bug Issue identified by VS Code Team member as probable bug label Jan 4, 2022
@rzhao271
Copy link
Contributor Author

rzhao271 commented Jan 4, 2022

execSync specifically comes with a windowsHide flag, that by default is set to false, meaning a new window pops up. When windowsHide is set to true, the npm command prompts do not pop up anymore. execSync also sets the shell option to true when it is not specified, before it calls spawnSync: https://github.com/nodejs/node/blob/ad747a8956ac4bdce1b4669310a93815447e6954/lib/child_process.js#L188

I can repro the issue with just the following main.js file:

const { app } = require('electron')
const cp = require('child_process');

function doSpawn () {
  cp.execSync('npm help version');
  cp.spawnSync('npm', ['version'], { shell: true });
}

app.whenReady().then(doSpawn);

@deepak1556
Copy link
Collaborator

Ignore testing from main.js, continue to test the same test case from a forked process off main (ELECTRON_RUN_AS_NODE) process as that is were we set the hide console window global flag explicitly. Next step with the reduced test case would be to find why the flag https://github.com/electron/electron/blob/b63c190fe6ac20f9b84e2813ab4c049862dc753a/shell/app/node_main.cc#L213-L214 is not having effect in this scenario.

@rzhao271
Copy link
Contributor Author

rzhao271 commented Jan 4, 2022

spawnSync has its own file that doesn't seem to go by the usual flow.
https://github.com/nodejs/node/blob/c85e67b600c07c0c37bebd077579f102747062a4/src/spawn_sync.cc#L808

I verified that if I added the following lines below, the consoles stop showing up on the screen:

if (env()->hide_console_windows())
    uv_process_options_.flags |= UV_PROCESS_WINDOWS_HIDE_CONSOLE;

Also, I'm aware that there's already a similar code snippet at https://github.com/nodejs/node/blob/c85e67b600c07c0c37bebd077579f102747062a4/src/process_wrap.cc#L241

@rzhao271 rzhao271 added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label Jan 4, 2022
@rzhao271
Copy link
Contributor Author

rzhao271 commented Jan 4, 2022

Actually, it looks like Electron forgot to carry over this patch

https://github.com/electron/electron/blob/13-x-y/patches/node/fix_don_t_create_console_window_when_creating_process.patch

I'll see if that patch fixes it + make a PR if needed.

@rzhao271 rzhao271 added the upstream-issue-fixed The underlying upstream issue has been fixed label Jan 7, 2022
deepak1556 added a commit that referenced this issue Jan 12, 2022
@bpasero bpasero added the verified Verification succeeded label Jan 28, 2022
bpasero added a commit that referenced this issue Feb 8, 2022
* chore: bump electron@15.3.0

* chore: bump node@16.x

* chore: enable render process reuse

* Revert "watcher - use `type` property for crash reporter location"

This reverts commit bfa488d.

* Revert "watcher - enable crash reports on linux (#136264)"

This reverts commit af26148.

* chore: enable crashpad on linux

* chore: bump electron@15.3.1

* chore: update api changes

* chore: bump @vscode/sqlite3@5.0.3

* spec: skip non-context aware module unittests

* chore: fix perf hook integration with node environment

* fix: adopt fs api changes

* chore: fix integration tests

* chore: bump electron@15.3.2

* chore: bump electron@16.0.0

* temp(macOS): kill test instances in OSS

* Revert "temp(macOS): kill test instances in OSS"

This reverts commit b0d796c.

* chore: update chromium version for clang downloader

* some 💄 changes

* align with changes

* adopt more fs.rm

* 💄

* chore: bump @vscode/sqlite3@5.0.4

* fix layers check to account for duplicated types from node.js

* update todo for type casts

* smoke - fix compile issue

* chore: update module cache

* watcher - fix unhandled rejection (fix #137416)

* ci: update node version

* enable stack dumping

* update electron types to 16.x

* chore: bump @vscode/sqlite3@5.0.5

Refs #137496

* fix layer issue

* add `AbortSignal` to core types

* chore: update linux compile flags

Refs electron/electron@797723e

* ci: fix linux build

* ci: update github ci cache

* ci: fix remote build in github ci

* ci: better fix for remote build

* chore: bump azure cache

* chore: fix merge conflict

* :chore: update to electron@16.0.2

* chore: bump @vscode/sqlite3@5.0.7

* ci: update to gcc-4.9 for remote

Refs #137659

* ci: switch to buster for linux arm

Refs #137927

* ci: fix build on linux arm64

* ci: fix arm client compiler toolchain

Refs #137927

* chore: bump electron@16.0.3

* ci: fix compile flags for the c toolchain

* chore: bump electron@16.0.4

* Add experimental dark mode flag (#139109)

* Add experimental dark mode flag

* Apply PR feedback

* chore: bump electron@16.0.6

* chore: bump electron@16.0.7

Fixes #138792
Fixes #139300

* chore: experimental highlight API

* smoke - fix compile issue

* FIXME: custom ELECTRON_RUN_AS_NODE with node worker

* Revert "chore: bump electron@16.0.7"

This reverts commit 5fd01cf.

* Revert "Revert "chore: bump electron@16.0.7""

This reverts commit a7f1b73.

* chore: fix github linux workflow

* chore: address review feedback

* chore: bump electron@16.0.8

* ci: revert to stretch distro for linux arm

Refs #137927

* ci: force build

* chore: update yarn.lock

* address feedback

* Revert "FIXME: custom ELECTRON_RUN_AS_NODE with node worker"

This reverts commit 7b48fa3.

* ci: fix remote folder build

* chore: fix github linux ci

* 🆙 `versionSpec`

Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com>
Co-authored-by: Raymond Zhao <raymondzhao@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Feb 26, 2022
lemanschik pushed a commit to code-oss-dev/code that referenced this issue Nov 25, 2022
* chore: bump electron@15.3.0

* chore: bump node@16.x

* chore: enable render process reuse

* Revert "watcher - use `type` property for crash reporter location"

This reverts commit bfa488d.

* Revert "watcher - enable crash reports on linux (microsoft#136264)"

This reverts commit af26148.

* chore: enable crashpad on linux

* chore: bump electron@15.3.1

* chore: update api changes

* chore: bump @vscode/sqlite3@5.0.3

* spec: skip non-context aware module unittests

* chore: fix perf hook integration with node environment

* fix: adopt fs api changes

* chore: fix integration tests

* chore: bump electron@15.3.2

* chore: bump electron@16.0.0

* temp(macOS): kill test instances in OSS

* Revert "temp(macOS): kill test instances in OSS"

This reverts commit b0d796c.

* chore: update chromium version for clang downloader

* some 💄 changes

* align with changes

* adopt more fs.rm

* 💄

* chore: bump @vscode/sqlite3@5.0.4

* fix layers check to account for duplicated types from node.js

* update todo for type casts

* smoke - fix compile issue

* chore: update module cache

* watcher - fix unhandled rejection (fix microsoft#137416)

* ci: update node version

* enable stack dumping

* update electron types to 16.x

* chore: bump @vscode/sqlite3@5.0.5

Refs microsoft#137496

* fix layer issue

* add `AbortSignal` to core types

* chore: update linux compile flags

Refs electron/electron@797723e

* ci: fix linux build

* ci: update github ci cache

* ci: fix remote build in github ci

* ci: better fix for remote build

* chore: bump azure cache

* chore: fix merge conflict

* :chore: update to electron@16.0.2

* chore: bump @vscode/sqlite3@5.0.7

* ci: update to gcc-4.9 for remote

Refs microsoft#137659

* ci: switch to buster for linux arm

Refs microsoft#137927

* ci: fix build on linux arm64

* ci: fix arm client compiler toolchain

Refs microsoft#137927

* chore: bump electron@16.0.3

* ci: fix compile flags for the c toolchain

* chore: bump electron@16.0.4

* Add experimental dark mode flag (microsoft#139109)

* Add experimental dark mode flag

* Apply PR feedback

* chore: bump electron@16.0.6

* chore: bump electron@16.0.7

Fixes microsoft#138792
Fixes microsoft#139300

* chore: experimental highlight API

* smoke - fix compile issue

* FIXME: custom ELECTRON_RUN_AS_NODE with node worker

* Revert "chore: bump electron@16.0.7"

This reverts commit 5fd01cf.

* Revert "Revert "chore: bump electron@16.0.7""

This reverts commit a7f1b73.

* chore: fix github linux workflow

* chore: address review feedback

* chore: bump electron@16.0.8

* ci: revert to stretch distro for linux arm

Refs microsoft#137927

* ci: force build

* chore: update yarn.lock

* address feedback

* Revert "FIXME: custom ELECTRON_RUN_AS_NODE with node worker"

This reverts commit 7b48fa3.

* ci: fix remote folder build

* chore: fix github linux ci

* 🆙 `versionSpec`

Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com>
Co-authored-by: Raymond Zhao <raymondzhao@microsoft.com>
lemanschik pushed a commit to code-oss-dev/code that referenced this issue Nov 25, 2022
* chore: bump electron@15.3.0

* chore: bump node@16.x

* chore: enable render process reuse

* Revert "watcher - use `type` property for crash reporter location"

This reverts commit bfa488d.

* Revert "watcher - enable crash reports on linux (microsoft#136264)"

This reverts commit af26148.

* chore: enable crashpad on linux

* chore: bump electron@15.3.1

* chore: update api changes

* chore: bump @vscode/sqlite3@5.0.3

* spec: skip non-context aware module unittests

* chore: fix perf hook integration with node environment

* fix: adopt fs api changes

* chore: fix integration tests

* chore: bump electron@15.3.2

* chore: bump electron@16.0.0

* temp(macOS): kill test instances in OSS

* Revert "temp(macOS): kill test instances in OSS"

This reverts commit b0d796c.

* chore: update chromium version for clang downloader

* some 💄 changes

* align with changes

* adopt more fs.rm

* 💄

* chore: bump @vscode/sqlite3@5.0.4

* fix layers check to account for duplicated types from node.js

* update todo for type casts

* smoke - fix compile issue

* chore: update module cache

* watcher - fix unhandled rejection (fix microsoft#137416)

* ci: update node version

* enable stack dumping

* update electron types to 16.x

* chore: bump @vscode/sqlite3@5.0.5

Refs microsoft#137496

* fix layer issue

* add `AbortSignal` to core types

* chore: update linux compile flags

Refs electron/electron@797723e

* ci: fix linux build

* ci: update github ci cache

* ci: fix remote build in github ci

* ci: better fix for remote build

* chore: bump azure cache

* chore: fix merge conflict

* :chore: update to electron@16.0.2

* chore: bump @vscode/sqlite3@5.0.7

* ci: update to gcc-4.9 for remote

Refs microsoft#137659

* ci: switch to buster for linux arm

Refs microsoft#137927

* ci: fix build on linux arm64

* ci: fix arm client compiler toolchain

Refs microsoft#137927

* chore: bump electron@16.0.3

* ci: fix compile flags for the c toolchain

* chore: bump electron@16.0.4

* Add experimental dark mode flag (microsoft#139109)

* Add experimental dark mode flag

* Apply PR feedback

* chore: bump electron@16.0.6

* chore: bump electron@16.0.7

Fixes microsoft#138792
Fixes microsoft#139300

* chore: experimental highlight API

* smoke - fix compile issue

* FIXME: custom ELECTRON_RUN_AS_NODE with node worker

* Revert "chore: bump electron@16.0.7"

This reverts commit 5fd01cf.

* Revert "Revert "chore: bump electron@16.0.7""

This reverts commit a7f1b73.

* chore: fix github linux workflow

* chore: address review feedback

* chore: bump electron@16.0.8

* ci: revert to stretch distro for linux arm

Refs microsoft#137927

* ci: force build

* chore: update yarn.lock

* address feedback

* Revert "FIXME: custom ELECTRON_RUN_AS_NODE with node worker"

This reverts commit 7b48fa3.

* ci: fix remote folder build

* chore: fix github linux ci

* 🆙 `versionSpec`

Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com>
Co-authored-by: Raymond Zhao <raymondzhao@microsoft.com>
lemanschik pushed a commit to code-oss-dev/code that referenced this issue Nov 25, 2022
* chore: bump electron@15.3.0

* chore: bump node@16.x

* chore: enable render process reuse

* Revert "watcher - use `type` property for crash reporter location"

This reverts commit bfa488d.

* Revert "watcher - enable crash reports on linux (microsoft#136264)"

This reverts commit af26148.

* chore: enable crashpad on linux

* chore: bump electron@15.3.1

* chore: update api changes

* chore: bump @vscode/sqlite3@5.0.3

* spec: skip non-context aware module unittests

* chore: fix perf hook integration with node environment

* fix: adopt fs api changes

* chore: fix integration tests

* chore: bump electron@15.3.2

* chore: bump electron@16.0.0

* temp(macOS): kill test instances in OSS

* Revert "temp(macOS): kill test instances in OSS"

This reverts commit b0d796c.

* chore: update chromium version for clang downloader

* some 💄 changes

* align with changes

* adopt more fs.rm

* 💄

* chore: bump @vscode/sqlite3@5.0.4

* fix layers check to account for duplicated types from node.js

* update todo for type casts

* smoke - fix compile issue

* chore: update module cache

* watcher - fix unhandled rejection (fix microsoft#137416)

* ci: update node version

* enable stack dumping

* update electron types to 16.x

* chore: bump @vscode/sqlite3@5.0.5

Refs microsoft#137496

* fix layer issue

* add `AbortSignal` to core types

* chore: update linux compile flags

Refs electron/electron@797723e

* ci: fix linux build

* ci: update github ci cache

* ci: fix remote build in github ci

* ci: better fix for remote build

* chore: bump azure cache

* chore: fix merge conflict

* :chore: update to electron@16.0.2

* chore: bump @vscode/sqlite3@5.0.7

* ci: update to gcc-4.9 for remote

Refs microsoft#137659

* ci: switch to buster for linux arm

Refs microsoft#137927

* ci: fix build on linux arm64

* ci: fix arm client compiler toolchain

Refs microsoft#137927

* chore: bump electron@16.0.3

* ci: fix compile flags for the c toolchain

* chore: bump electron@16.0.4

* Add experimental dark mode flag (microsoft#139109)

* Add experimental dark mode flag

* Apply PR feedback

* chore: bump electron@16.0.6

* chore: bump electron@16.0.7

Fixes microsoft#138792
Fixes microsoft#139300

* chore: experimental highlight API

* smoke - fix compile issue

* FIXME: custom ELECTRON_RUN_AS_NODE with node worker

* Revert "chore: bump electron@16.0.7"

This reverts commit 5fd01cf.

* Revert "Revert "chore: bump electron@16.0.7""

This reverts commit a7f1b73.

* chore: fix github linux workflow

* chore: address review feedback

* chore: bump electron@16.0.8

* ci: revert to stretch distro for linux arm

Refs microsoft#137927

* ci: force build

* chore: update yarn.lock

* address feedback

* Revert "FIXME: custom ELECTRON_RUN_AS_NODE with node worker"

This reverts commit 7b48fa3.

* ci: fix remote folder build

* chore: fix github linux ci

* 🆙 `versionSpec`

Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com>
Co-authored-by: Raymond Zhao <raymondzhao@microsoft.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member electron-16-update Issues related to electron 16 update upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-fixed The underlying upstream issue has been fixed verified Verification succeeded windows VS Code on Windows issues
Projects
None yet
Development

No branches or pull requests

4 participants