fix(core): Retry each file removal in the byte store's delete (#39193)

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Emilia 2026-09-28 07:20:44 +00:00 committed by GitHub
parent 3a31c38751
commit 7bebbe4033
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -125,6 +125,18 @@ describe('delete', () => {
it('does not throw on deleting a missing key', async () => {
await expect(store.delete(['a/missing.json'])).resolves.toBeUndefined();
});
it('passes a retry budget to each file removal', async () => {
await store.write('a/one.json', body);
const rmSpy = vi.spyOn(fs, 'rm');
await store.delete(['a/one.json']);
expect(rmSpy).toHaveBeenCalledWith(join(storagePath, 'a/one.json'), {
force: true,
maxRetries: 3,
});
});
});
describe('write (stream)', () => {

View File

@ -94,7 +94,7 @@ export class FsByteStore implements ByteStore {
async delete(keys: ByteStoreKey[]) {
const deletePaths = keys.map((key) => this.getAbsolutePath(key));
await Promise.all(deletePaths.map(async (p) => await fs.rm(p, { force: true })));
await Promise.all(deletePaths.map(async (p) => await fs.rm(p, { force: true, maxRetries: 3 })));
const dirs = [...new Set(deletePaths.map((p) => path.dirname(p)))];
await Promise.all(dirs.map(async (dir) => await this.removeEmptyAncestors(dir)));
}