Skip to content

Commit 684111c

Browse files
committed
perf(ipc): use safeDeleteSync for immediate synchronous deletion
Changes: - Replace safeDelete with safeDeleteSync in readIpcStub - Replace safeDelete with safeDeleteSync in cleanupIpcStubs - Improves reliability in CI environments with filesystem delays - Ensures deletion completes before continuing execution Benefits: - Eliminates async timing issues with file deletion - More predictable behavior in tests - Simpler error handling (no promise rejection handling needed)
1 parent 199dec9 commit 684111c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/ipc.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import crypto from 'node:crypto'
3232
import { promises as fs } from 'node:fs'
3333
import path from 'node:path'
3434

35-
import { safeDelete } from './fs'
35+
import { safeDeleteSync } from './fs'
3636
import { getOsTmpDir } from './paths'
3737
import { z } from './zod'
3838

@@ -329,7 +329,11 @@ export async function readIpcStub(stubPath: string): Promise<unknown> {
329329
const maxAgeMs = 5 * 60 * 1000
330330
if (ageMs > maxAgeMs) {
331331
// Clean up stale file. IPC stubs are always in tmpdir, so use force: true.
332-
await safeDelete(stubPath, { force: true }).catch(() => {})
332+
try {
333+
safeDeleteSync(stubPath, { force: true })
334+
} catch {
335+
// Ignore deletion errors
336+
}
333337
return null
334338
}
335339
return validated.data
@@ -396,7 +400,7 @@ export async function cleanupIpcStubs(appName: string): Promise<void> {
396400

397401
if (isStale) {
398402
// IPC stubs are always in tmpdir, so we can use force: true to skip path checks
399-
await safeDelete(filePath, { force: true })
403+
safeDeleteSync(filePath, { force: true })
400404
}
401405
} catch {
402406
// Ignore errors for individual files.

0 commit comments

Comments
 (0)