fix(project): stabilize project deletion
- 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
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user