fix: afterAll cleanup robustness for verify-d2-upload-retry
- rmSync with maxRetries handles ENOTEMPTY from overlayfs WAL races - try/catch catch: async retryJob IIFE may recreate files during cleanup - CI container ephemeral, /tmp leftovers harmless All 17 test files (220 tests) pass, svelte-check: 0 errors.
This commit is contained in:
@@ -2,7 +2,7 @@ import { describe, it, expect, afterAll, vi } from 'vitest';
|
||||
import { join } from 'path';
|
||||
import { tmpdir } from 'os';
|
||||
import { rm, mkdir, writeFile } from 'fs/promises';
|
||||
import { existsSync } from 'fs';
|
||||
import { existsSync, rmSync } from 'fs';
|
||||
import Database from 'better-sqlite3';
|
||||
|
||||
/**
|
||||
@@ -27,8 +27,14 @@ const { getJob } = await import('$lib/server/db.js');
|
||||
const { POST } = await import('$lib/../routes/api/jobs/[id]/retry/+server.js');
|
||||
const { GET } = await import('$lib/../routes/api/jobs/+server.js');
|
||||
|
||||
afterAll(async () => {
|
||||
await rm(TEST_DATA_DIR, { recursive: true, force: true });
|
||||
afterAll(() => {
|
||||
try {
|
||||
// rmSync with maxRetries handles ENOTEMPTY/EBUSY from WAL/filesystem races
|
||||
rmSync(TEST_DATA_DIR, { recursive: true, force: true, maxRetries: 3 });
|
||||
} catch {
|
||||
// Best-effort: retryJob's async IIFE may recreate files during cleanup.
|
||||
// CI container is ephemeral — leftover /tmp files are harmless.
|
||||
}
|
||||
});
|
||||
|
||||
function makeEvent(jobId: string) {
|
||||
|
||||
Reference in New Issue
Block a user