mirror of
https://github.com/garrytan/gstack.git
synced 2026-08-16 03:00:40 +02:00
fix: restore isProcessAlive boolean semantics, add safeUnlinkQuiet, remove unused json()
isProcessAlive now catches ALL errors and returns false (pure boolean probe). Callers use it in if/while conditions without try/catch, so throwing on EPERM was a behavior change that could crash the CLI. Windows path gets its safety catch restored. safeUnlinkQuiet added for best-effort cleanup paths where throwing on non-ENOENT errors (like EPERM during shutdown) would abort cleanup. json() removed — dead code, never imported anywhere. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
5f9246ac23
commit
6a857d41ba
@@ -2,7 +2,7 @@ import { describe, test, expect } from 'bun:test';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { safeUnlink, safeKill, isProcessAlive, json } from '../src/error-handling';
|
||||
import { safeUnlink, safeKill, isProcessAlive } from '../src/error-handling';
|
||||
|
||||
describe('safeUnlink', () => {
|
||||
test('removes an existing file', () => {
|
||||
@@ -45,20 +45,3 @@ describe('isProcessAlive', () => {
|
||||
expect(isProcessAlive(99999999)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('json', () => {
|
||||
test('returns Response with JSON body and correct Content-Type', async () => {
|
||||
const resp = json({ ok: true });
|
||||
expect(resp.status).toBe(200);
|
||||
expect(resp.headers.get('Content-Type')).toBe('application/json');
|
||||
const body = await resp.json();
|
||||
expect(body).toEqual({ ok: true });
|
||||
});
|
||||
|
||||
test('uses custom status code', async () => {
|
||||
const resp = json({ error: 'not found' }, 404);
|
||||
expect(resp.status).toBe(404);
|
||||
const body = await resp.json();
|
||||
expect(body).toEqual({ error: 'not found' });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user