Skip to content

Commit eb2eb5f

Browse files
committed
fix(ipc): use safeDelete for cleaning up stub files
Replace fs.unlink with safeDelete for deleting IPC stub files in cleanupIpcStubs and readIpcStub functions. The safeDelete function automatically sets force: true for files in os.tmpdir(), which is required for reliable deletion in CI environments. IPC stub files are created in os.tmpdir()/.socket-ipc/{appName}/ which is outside the user's cwd, so using safeDelete with its automatic force flag is the correct approach. Fixes test failure: "should clean up stale stub files"
1 parent 6f33b87 commit eb2eb5f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ipc.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { promises as fs } from 'node:fs'
3333
import os from 'node:os'
3434
import path from 'node:path'
3535

36+
import { safeDelete } from './fs'
3637
import { z } from './zod'
3738

3839
// Define BufferEncoding type for TypeScript compatibility.
@@ -328,7 +329,7 @@ export async function readIpcStub(stubPath: string): Promise<unknown> {
328329
const maxAgeMs = 5 * 60 * 1000
329330
if (ageMs > maxAgeMs) {
330331
// Clean up stale file.
331-
await fs.unlink(stubPath).catch(() => {})
332+
await safeDelete(stubPath).catch(() => {})
332333
return null
333334
}
334335
return validated.data
@@ -394,7 +395,7 @@ export async function cleanupIpcStubs(appName: string): Promise<void> {
394395
}
395396

396397
if (isStale) {
397-
await fs.unlink(filePath)
398+
await safeDelete(filePath)
398399
}
399400
} catch {
400401
// Ignore errors for individual files.

0 commit comments

Comments
 (0)