Skip to content

[Bug] Visible terminal windows on Windows when osgrep serve spawns workers #75

Description

@ivanjuras

[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

  1. Install osgrep globally: npm install -g osgrep
  2. Enable the osgrep plugin in Claude Code
  3. Start a Claude Code session (plugin triggers osgrep serve on SessionStart)
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions