Skip to content

fix(child_process): hide worker consoles on Windows - #146

Open
iki wants to merge 1 commit into
tinylibs:mainfrom
iki:codex/windows-hide-process-workers-2.2.0
Open

iki wants to merge 1 commit into
tinylibs:mainfrom
iki:codex/windows-hide-process-workers-2.2.0

Conversation

@iki

@iki iki commented Nov 6, 2026

Copy link
Copy Markdown

Child-process workers currently omit windowsHide when calling fork(), allowing an extra console window when a Windows consumer is launched from a graphical application.

Request windowsHide: true while preserving piped stdout/stderr (as established in #104), explicit environment values, IPC, task results and joined shutdown. The option is forwarded to spawn(); Node 20's cluster implementation also passes it to fork.

The local options object uses satisfies SpawnOptions because the pinned @types/node@20.12.8 omits this member from ForkOptions. The declaration was corrected later in DefinitelyTyped #75525. This keeps the existing dependency pins and lockfile, with no cast or suppression.

Regression coverage:

  • Intercept fork() before any worker starts and verify the hiding flag, pipes, arguments and explicit environment. Restore the builtin export after interception.
  • Run a real process worker, verify its result, environment and IPC, then confirm destruction waits for its exit.

Validated on Windows with Node 26.13.0 and pnpm 9.0.6 against the built package:

  • The new launch-options test failed on unchanged v2.2.0 because windowsHide was absent.
  • 18 runtime tests, 2 stdio tests and 2 non-nested termination tests passed.
  • Frozen installation, build, typecheck and lint passed.

Each test file ran in a separate owned process. The CPU-scaled nested stress case and remaining full suite were not run locally; they remain unchanged for upstream CI. These tests verify the requested option and worker behavior, not native console-window visibility.

Reusable source: fork branch, tested signed commit, based directly on v2.2.0 (2ed306417986823e7a7989fd392e9cbfeee1b0c1). With pnpm 9.0.6:

pnpm install --frozen-lockfile
pnpm build
pnpm exec vitest run test/runtime.test.ts --maxWorkers=1
pnpm exec vitest run test/worker-stdio.test.ts --maxWorkers=1
pnpm typecheck
pnpm lint

Build the generated dist files before consuming this source checkout; a bare Git dependency URL is not a built release artifact.

Forward windowsHide to the worker fork while preserving pipes, environment,
IPC and joined shutdown. Validate the options with SpawnOptions so the pinned
Node 20 declarations need no upgrade or suppression.

Add a no-launch fork regression and a real process-worker lifecycle test.
The new launch-options test fails before the fix. Windows Node 26.13.0:
22 focused tests, build, typecheck and lint pass; native window visibility
and the CPU-scaled full suite were not measured locally.

Based on Tinypool v2.2.0 (2ed3064).
Reusable source: pnpm 9.0.6 install --frozen-lockfile, then pnpm build.
Regression: pnpm exec vitest run test/runtime.test.ts --maxWorkers=1.
Build generated dist before consuming this source checkout.
@iki

iki commented Nov 20, 2026 •

Copy link
Copy Markdown
Author

I tested the published Tinypool 2.2.0 selected by Oxfmt 0.79.0 on Windows x64 with Bun 1.4.2. In two separate frozen installations, intercepting the formatter’s resolved Tinypool instance showed that stock fork() omitted windowsHide and the package patch set it to true. Both calls preserved piped stdio and the explicit environment value.

In separate processes, both installs returned 42 for a real worker given 41, completed destroy() with the worker process gone, and formatted JavaScript through Oxfmt. This checks the launch options and joined worker lifetime. The CI and Publish Any Commit workflows on this PR currently show action_required.

On Bun 1.4.5 for Windows x64, I repeated the fork interception and real-worker tests against Oxfmt 0.79.0’s own Tinypool 2.2.0 installation. The published package omitted windowsHide and the existing patch set it to true. Piped stdio, the supplied environment entry, the 41-to-42 worker task, worker shutdown and actual formatting all passed in both installs.

On November 28 I repeated the Windows x64 check with Oxfmt 0.80.0, which resolves Tinypool 2.2.0. The pristine fork omitted windowsHide and the patched fork set it to true under both Bun 1.4.5 and 1.4.2. All four runs preserved piped stdio and the supplied environment entry, returned 42 from the worker for input 41, reaped the child on destroy(), and formatted stdin.

On December 3 I repeated the Windows x64 checks with Oxfmt 0.81.0, which selects Tinypool 2.2.0. On Bun 1.4.5 and 1.4.2 the stock worker fork omitted windowsHide and the patched fork set it to true. All four runs preserved piped stdio and the supplied environment entry, returned 42 for input 41, reaped the worker on shutdown, and formatted stdin. Oxfmt 0.81.0 dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant