fix(browse): stop the Bun polyfill flashing console windows on Windows#2290
Open
WimvandenHeijkant wants to merge 1 commit into
Open
fix(browse): stop the Bun polyfill flashing console windows on Windows#2290WimvandenHeijkant wants to merge 1 commit into
WimvandenHeijkant wants to merge 1 commit into
Conversation
The Node bun-polyfill forwards Bun.spawn/spawnSync to child_process without windowsHide. Node defaults that option to false, so on Windows every child the browse server starts opens a console window -- Bun itself does not behave this way, so the polyfill was drifting from the API it emulates. The visible symptom is an empty black bun.exe window appearing every ~60s: server.ts's agent watchdog respawns a crashed terminal-agent on each tick, and the agent is spawned with stdio ['ignore','ignore', 'ignore'], so the window it opens has nothing in it. The tasklist, powershell and chrome --version helpers pop windows the same way. Fixed at the polyfill rather than the call sites, since it is the one choke point every Bun.spawn under Node passes through. An explicit windowsHide: false is still honoured for callers that want a visible console. Verified against the unpatched polyfill (spawn/spawnSync both received undefined) and the patched one (both receive true, explicit false still wins). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Author
|
/trunk merge |
|
An error occurred while submitting your PR to the queue: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The symptom
On Windows, using any browse-backed skill pops up empty black
bun.execonsole windows — one roughly every 60 seconds, with nothing in them.The cause
browse/src/bun-polyfill.cjssupplies aBunglobal so the bundledbrowse/dist/server-node.mjscan run under Node. Itsspawn/spawnSyncforward tochild_processwithoutwindowsHide, and Node defaults that tofalse— so every child gets a console window on Windows. RealBun.spawndoesn't do this, so the polyfill was quietly drifting from the API it emulates.Two details explain the exact symptom:
browse/src/server.ts(GSTACK_AGENT_WATCHDOG_TICK_MS, default 60000) respawns theterminal-agentwhen it isn't alive. A crash-looping agent therefore yields a fresh window per tick.stdio: ['ignore', 'ignore', 'ignore'], so the window it opens has no output in it.It isn't only the terminal-agent — the
tasklist,powershell, andchrome --versionhelpers all flow through the same polyfill and pop windows too.The fix
windowsHide: options.windowsHide !== falseon both polyfill spawn paths. Fixed at the polyfill rather than at each call site because it's the single choke point everyBun.spawnunder Node passes through. An explicitwindowsHide: falsestill wins, so anyone who genuinely wants a visible console keeps the escape hatch.Verification
Intercepted
child_processand compared the current polyfill against the patched one:spawnSyncspawnwindowsHide: falseundefinedundefinedundefinedtruetruefalseundefinedis what Node reads as false — hence the window.Added two regression tests to
browse/test/bun-polyfill.test.ts, following the file's existing "require the polyfill in a Node subprocess" style. They assert the option reacheschild_processrather than trying to observe a window, so they're meaningful on Linux CI too. Confirmed they fail against the unpatched polyfill and pass against the patched one.Notes for the reviewer
server-node.mjsuses. TheBun.spawncall inbrowse/src/terminal-agent-control.ts(the real-Bun path, used by the compiledbrowse.exe) is untouched — I couldn't verify real-Bun window behaviour on this machine and didn't want to guess. Happy to extend if you know it needs the same treatment.browse/test/bun-polyfill.test.tscurrently can't run on Windows at all, independent of this PR: it interpolates an absolute path into anode -estring, so on Windowsrequire('C:\Users\...')hits invalid\U/\Aescapes, and two tests also assume a POSIXecho. Left alone as out of scope — mentioning it since this is a Windows fix whose tests only actually execute on Linux.VERSION/CHANGELOG.mdbump, soversion-gatedoesn't trigger. Let me know if you'd like one.🤖 Generated with Claude Code