idle-kill.integration.test.ts 1.1 KB

123456789101112131415161718192021222324252627282930
  1. // Integration test for CLAUDE.md §7.3 — isolates idle longer than
  2. // `idleKillMs` get retired by the sweeper. The next invocation must
  3. // cold-start a fresh process (different PID). We use the test-only
  4. // `triggerIdleCheck()` hook on `IsolatePoolImpl` to drive the sweeper
  5. // deterministically rather than wait for the 30s production interval.
  6. import { describe, expect, test } from 'bun:test';
  7. import { runIdleKillFixture } from './test-helpers.js';
  8. describe('idle kill (integration)', () => {
  9. test('isolate killed after idleKillMs elapses; next invoke cold-starts', async () => {
  10. const { firstPid, secondPid, cleanup } = await runIdleKillFixture({
  11. fnName: 'v',
  12. deploymentId: 'd1',
  13. idleKillMs: 100, // tiny idle threshold
  14. fnSource: `
  15. import { query } from '@briven/cli/server';
  16. export const v = query(async () => 'ok');
  17. `,
  18. });
  19. try {
  20. expect(firstPid).toBeGreaterThan(0);
  21. expect(secondPid).toBeGreaterThan(0);
  22. expect(firstPid).not.toBe(secondPid);
  23. } finally {
  24. await cleanup();
  25. }
  26. }, 30_000);
  27. });