ffce066842
- Guard renderer project list/get against stale initial loads - Retry project zip/cache removal to handle transient Windows locks - Surface deletion failures in UI and add regression tests Made-with: Cursor
32 lines
864 B
TypeScript
32 lines
864 B
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
import { rmWithRetries } from './fsRetry';
|
|
|
|
void test('rmWithRetries: retries on EPERM and then succeeds', async () => {
|
|
let calls = 0;
|
|
const rm = () => {
|
|
calls += 1;
|
|
if (calls < 3) {
|
|
const err = new Error('nope') as Error & { code: string };
|
|
err.code = 'EPERM';
|
|
throw err;
|
|
}
|
|
return Promise.resolve();
|
|
};
|
|
await rmWithRetries(rm, 'x', { force: true }, 5);
|
|
assert.equal(calls, 3);
|
|
});
|
|
|
|
void test('rmWithRetries: does not retry on ENOENT', async () => {
|
|
let calls = 0;
|
|
const rm = () => {
|
|
calls += 1;
|
|
const err = new Error('missing') as Error & { code: string };
|
|
err.code = 'ENOENT';
|
|
return Promise.reject(err);
|
|
};
|
|
await assert.rejects(() => rmWithRetries(rm, 'x', { force: true }, 5), /missing/);
|
|
assert.equal(calls, 1);
|
|
});
|