mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 18:18:21 +00:00
fix(cursor): clean up PID file on startDaemon failure and improve daemon robustness
- Add removePidFile() in safeResolve on failure to prevent stale PIDs - Only send SIGKILL in stopDaemon if SIGTERM wait loop exhausted - Check isDaemonRunning before model fetch to avoid 5s timeout - Add port validation unit tests for startDaemon
This commit is contained in:
1 parent
887efa4069
commit
cda037e7e5
3 files changed
+34
-5
No files matched your search
@@ -13,6 +13,7 @@ import {
|
||||
isDaemonRunning,
|
||||
getDaemonStatus,
|
||||
stopDaemon,
|
||||
startDaemon,
|
||||
} from '../../../src/cursor/cursor-daemon';
|
||||
|
||||
// Test isolation
|
||||
@@ -116,6 +117,26 @@ describe('removePidFile', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('startDaemon', () => {
|
||||
it('rejects invalid port (0)', async () => {
|
||||
const result = await startDaemon({ port: 0, model: 'test' });
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.error).toContain('Invalid port');
|
||||
});
|
||||
|
||||
it('rejects invalid port (65536)', async () => {
|
||||
const result = await startDaemon({ port: 65536, model: 'test' });
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.error).toContain('Invalid port');
|
||||
});
|
||||
|
||||
it('rejects non-integer port', async () => {
|
||||
const result = await startDaemon({ port: 3.14, model: 'test' });
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.error).toContain('Invalid port');
|
||||
});
|
||||
});
|
||||
|
||||
describe('isDaemonRunning', () => {
|
||||
it('returns false when no daemon is running on port', async () => {
|
||||
// Use a port that should not have anything running
|
||||
|
||||
Reference in new issue
Block a user