Skip to content

Commit c83c6ef

Browse files
committed
Fix isProcessAlive using require() in ESM — broke all Node.js Windows tests
The Windows process check used `require('child_process')` which doesn't exist in Node.js ESM modules (only works in Bun which supports require in ESM). This caused every isProcessAlive() call to throw, be caught, and return false — making all bridge processes appear dead. Cascading effects: sessions always showed "crashed", PIDs were null (bridges got unnecessarily restarted), close couldn't send HTTP DELETE (thought bridge was dead), and proxy stayed alive after close. Fix: import execFileSync at module top level (ESM-compatible) and use execFileSync instead of execSync (also avoids shell injection). https://claude.ai/code/session_01QA2R1dDEWRrdGUAbX9Qz9B
1 parent 35a2cd7 commit c83c6ef

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/lib/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import { createHash } from 'crypto';
7+
import { execFileSync } from 'child_process';
78
import { homedir } from 'os';
89
import { join, resolve, isAbsolute } from 'path';
910
import { mkdir, access, constants } from 'fs/promises';
@@ -332,9 +333,7 @@ export function isProcessAlive(pid: number): boolean {
332333
*/
333334
function isProcessAliveWindows(pid: number): boolean {
334335
try {
335-
// eslint-disable-next-line @typescript-eslint/no-require-imports
336-
const { execSync } = require('child_process') as typeof import('child_process');
337-
const output = execSync(`tasklist /FI "PID eq ${pid}" /NH`, {
336+
const output = execFileSync('tasklist', ['/FI', `PID eq ${pid}`, '/NH'], {
338337
encoding: 'utf-8',
339338
stdio: ['pipe', 'pipe', 'pipe'],
340339
timeout: 5000,

0 commit comments

Comments
 (0)