Skip to content

Detach non-wait PowerShell launches - #370

Closed
puneetdixit200 wants to merge 2 commits into
sindresorhus:mainfrom
puneetdixit200:fix-nonwait-detach
Closed

Detach non-wait PowerShell launches#370
puneetdixit200 wants to merge 2 commits into
sindresorhus:mainfrom
puneetdixit200:fix-nonwait-detach

Conversation

@puneetdixit200

Copy link
Copy Markdown

Summary:

  • detach non-wait PowerShell launches after stdio is ignored so Windows targets can keep opening after the parent process exits
  • add an AVA regression test that loads the module with process.platform mocked to win32 and verifies the spawn options

Tests:

  • npm_config_cache=/tmp/open-npm-cache npx ava test.js --match="detaches PowerShell launches when not waiting on Windows"
  • npm_config_cache=/tmp/open-npm-cache npx ava test.js --match="app launches resolve before close without fallback" --match="detaches PowerShell launches when not waiting on Windows"
  • npm_config_cache=/tmp/open-npm-cache npm test
  • git diff --check

Fixes #367

@sindresorhus

Copy link
Copy Markdown
Owner

Could you also set windowsHide: true when using detached: true here?

I double checked the Node docs, and on Windows a detached child process gets its own console window, while windowsHide defaults to false. Since this is the normal non-wait open() path, this could make a PowerShell window flash or show up for every call.

And make sure you test manually in PowerShell after this to confirm it works fine. I want to see a screenshot of it too, to confirm, since this PR is clearly AI generated and I don't really trust it.

Set windowsHide when detaching non-wait PowerShell launches on Windows, and assert the spawn option in the Windows regression test.
@puneetdixit200

Copy link
Copy Markdown
Author

Updated in 6b71ed2: the non-wait PowerShell path now sets windowsHide: true together with detached: true and stdio: "ignore", and the regression test asserts those spawn options.

Local validation run on macOS:

  • npm install --package-lock=false --cache /tmp/open-370-npm-cache --no-audit
  • npm test
  • npm exec ava -- test.js -m "detaches PowerShell launches when not waiting on Windows"
  • git diff --check

I cannot provide the requested PowerShell screenshot from this macOS environment; that manual Windows validation still needs to be done on a Windows machine.

@sindresorhus

Copy link
Copy Markdown
Owner

As I expected, just AI slop.

Repository owner locked and limited conversation to collaborators May 25, 2026
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.

Can't open a local file anymore in v11

2 participants