fix(server): launch Glimpse via node on Windows instead of unspawnable npm shim (#861)

On Windows, Bun.which("glimpseui") resolves to an npm script shim (.cmd / extensionless shebang), which spawn() cannot launch without a shell: it throws EINVAL on .cmd and ENOENT on the shim, so openGlimpse() always returned false and plannotator fell back to the browser. shell:true is not viable because it severs the stdin HTML pipe (glimpse.mjs then exits 1). Resolve the package entry and run it with node directly instead.
This commit is contained in:
Oleksii Nikiforov
2026-06-05 18:52:33 +03:00
committed by GitHub
parent 3de555f5e5
commit 3bde235a85
+21 -1
View File
@@ -139,6 +139,26 @@ async function openGlimpse(url: string): Promise<boolean> {
];
const html = buildGlimpseHtml(url);
// On Windows, `glimpseui` resolves to an npm script shim, not an exe, which
// spawn() can't launch without a shell. `shell: true` would break the stdin
// HTML pipe below, so run the package entry with node directly instead.
let command = glimpseCli;
let spawnArgs = args;
if (process.platform === "win32" && !/\.exe$/i.test(glimpseCli)) {
const node = Bun.which("node");
const entry = path.join(
path.dirname(glimpseCli),
"node_modules",
"glimpseui",
"bin",
"glimpse.mjs"
);
if (node && fs.existsSync(entry)) {
command = node;
spawnArgs = [entry, ...args];
}
}
return await new Promise<boolean>((resolve) => {
let settled = false;
let successTimer: ReturnType<typeof setTimeout> | undefined;
@@ -149,7 +169,7 @@ async function openGlimpse(url: string): Promise<boolean> {
resolve(opened);
};
const child = spawn(glimpseCli, args, {
const child = spawn(command, spawnArgs, {
detached: true,
stdio: ["pipe", "ignore", "ignore"],
});