[Bug] Visible terminal windows on Windows when osgrep serve spawns workers
Description
When using osgrep serve on Windows, 4 visible Node.js terminal windows appear and remain open. If you try to close one, it respawns to maintain 4 windows. This is disruptive to the user experience.
The issue is caused by missing windowsHide: true option in spawn() and fork() calls. On Windows, Node.js child processes open visible console windows by default unless windowsHide: true is specified.
Environment
- OS: Windows 10/11
- Node.js: v20+
- osgrep version: Latest (installed via npm)
- Usage: Claude Code plugin (
osgrep@osgrep)
Steps to Reproduce
- Install osgrep globally:
npm install -g osgrep
- Enable the osgrep plugin in Claude Code
- Start a Claude Code session (plugin triggers
osgrep serve on SessionStart)
- Observe: 4 Node.js terminal windows appear and stay open
Root Cause
Three locations are missing windowsHide: true:
1. Plugin start hook
File: plugins/osgrep/hooks/start.js (line 20-24)
const child = spawn("osgrep", ["serve"], {
cwd,
detached: true,
stdio: ["ignore", out, out],
// MISSING: windowsHide: true
});
2. Serve background spawn
File: dist/commands/serve.js (line ~86-90)
const child = spawn(process.argv[0], [process.argv[1], ...args], {
detached: true,
stdio: ["ignore", out, err],
cwd: process.cwd(),
// MISSING: windowsHide: true
env: { ...process.env, OSGREP_BACKGROUND: "true" },
});
3. Worker pool fork
File: dist/lib/workers/pool.js (line ~91)
this.child = childProcess.fork(modulePath, {
execArgv,
env: Object.assign({}, process.env),
// MISSING: windowsHide: true
});
Suggested Fix
Add windowsHide: true to all three spawn/fork calls:
// plugins/osgrep/hooks/start.js
const child = spawn("osgrep", ["serve"], {
cwd,
detached: true,
stdio: ["ignore", out, out],
windowsHide: true, // ADD THIS
});
// dist/commands/serve.js
const child = spawn(process.argv[0], [process.argv[1], ...args], {
detached: true,
stdio: ["ignore", out, err],
cwd: process.cwd(),
windowsHide: true, // ADD THIS
env: { ...process.env, OSGREP_BACKGROUND: "true" },
});
// dist/lib/workers/pool.js
this.child = childProcess.fork(modulePath, {
execArgv,
env: Object.assign({}, process.env),
windowsHide: true, // ADD THIS
});
Workaround
Users can manually patch their local npm installation at:
%APPDATA%\npm\node_modules\osgrep\plugins\osgrep\hooks\start.js
%APPDATA%\npm\node_modules\osgrep\dist\commands\serve.js
%APPDATA%\npm\node_modules\osgrep\dist\lib\workers\pool.js
However, this patch is lost on npm update osgrep.
Additional Context
[Bug] Visible terminal windows on Windows when osgrep serve spawns workers
Description
When using
osgrep serveon Windows, 4 visible Node.js terminal windows appear and remain open. If you try to close one, it respawns to maintain 4 windows. This is disruptive to the user experience.The issue is caused by missing
windowsHide: trueoption inspawn()andfork()calls. On Windows, Node.js child processes open visible console windows by default unlesswindowsHide: trueis specified.Environment
osgrep@osgrep)Steps to Reproduce
npm install -g osgreposgrep serveon SessionStart)Root Cause
Three locations are missing
windowsHide: true:1. Plugin start hook
File:
plugins/osgrep/hooks/start.js(line 20-24)2. Serve background spawn
File:
dist/commands/serve.js(line ~86-90)3. Worker pool fork
File:
dist/lib/workers/pool.js(line ~91)Suggested Fix
Add
windowsHide: trueto all three spawn/fork calls:Workaround
Users can manually patch their local npm installation at:
%APPDATA%\npm\node_modules\osgrep\plugins\osgrep\hooks\start.js%APPDATA%\npm\node_modules\osgrep\dist\commands\serve.js%APPDATA%\npm\node_modules\osgrep\dist\lib\workers\pool.jsHowever, this patch is lost on
npm update osgrep.Additional Context
windowsHideoption is ignored on non-Windows platforms, so adding it won't affect other OSes