Skip to content

Commit de1b5da

Browse files
Copilotpethers
andcommitted
fix: mock sleep in retry tests to prevent OOM + use single thread
1. Mocked client.sleep() in mcp-client-core-part2.test.js error counting tests - Tests were taking 3005ms each with real retries (1000ms + 2000ms delays) - Now take ~1ms with mocked sleep - Reduces async work and memory pressure 2. Changed vitest config to singleThread: true - Reduces worker thread memory pressure - Tests still pass, just slightly slower The OOM issue is caused by cumulative memory pressure from 14 test files running together. Even with these fixes, OOM still occurs but is improved. Further investigation needed - may need to split more files or increase Node memory limit in CI. Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
1 parent 3bc9b24 commit de1b5da

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

tests/mcp-client-core-part2.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ describe('MCPClient Part 2', () => {
365365

366366
describe('error counting accuracy', () => {
367367
it('should not over-count errors on retried requests', async () => {
368+
// Mock sleep to make test fast (prevent 3000ms delay causing OOM)
369+
vi.spyOn(client, 'sleep').mockResolvedValue();
370+
368371
let attempt = 0;
369372
global.fetch = vi.fn(() => {
370373
attempt++;
@@ -386,6 +389,9 @@ describe('MCPClient Part 2', () => {
386389
});
387390

388391
it('should count exactly one error for a fully failed request', async () => {
392+
// Mock sleep to make test fast (prevent 3000ms delay causing OOM)
393+
vi.spyOn(client, 'sleep').mockResolvedValue();
394+
389395
global.fetch = vi.fn(() => Promise.reject(new Error('Network error')));
390396

391397
try {

vitest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default defineConfig({
108108

109109
// Pool options for parallel execution (Vitest 4+)
110110
pool: 'threads',
111-
singleThread: false,
111+
singleThread: true, // Single thread to reduce memory pressure
112112

113113
// Mock configuration
114114
mockReset: true,

0 commit comments

Comments
 (0)