mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-07 16:35:48 +01:00
test(server): restore write access before removing the vitest home
Runtime-context bundles are published read-only (0o555 directories), so the worker-exit rmSync of the per-worker PAPERCLIP_HOME failed with EACCES. Vitest reports that as an unhandled error and fails the shard even when every test passes (server (11/12) on #15962, twice). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d37c03c236
commit
fea261262e
1 file changed
+12
-1
@@ -27,9 +27,20 @@ process.env.PAPERCLIP_TEST_HOST_HOME ??= process.env.PAPERCLIP_HOME?.trim() || p
|
|||||||
// Receipt-spool recovery must never scan a developer's instance during tests.
|
// Receipt-spool recovery must never scan a developer's instance during tests.
|
||||||
const paperclipTestHome = fs.mkdtempSync(path.join(os.tmpdir(), "paperclip-vitest-home-"));
|
const paperclipTestHome = fs.mkdtempSync(path.join(os.tmpdir(), "paperclip-vitest-home-"));
|
||||||
process.env.PAPERCLIP_HOME = paperclipTestHome;
|
process.env.PAPERCLIP_HOME = paperclipTestHome;
|
||||||
|
// Runtime-context bundles are published read-only (0o555 directories), so
|
||||||
|
// restore owner write access on directories before removing the tree.
|
||||||
|
function restoreDirectoryWriteAccess(target: string): void {
|
||||||
|
const stat = fs.lstatSync(target, { throwIfNoEntry: false });
|
||||||
|
if (!stat?.isDirectory()) return;
|
||||||
|
fs.chmodSync(target, 0o700);
|
||||||
|
for (const entry of fs.readdirSync(target)) restoreDirectoryWriteAccess(path.join(target, entry));
|
||||||
|
}
|
||||||
// Setup-file afterAll hooks run before suites drain asynchronous heartbeats.
|
// Setup-file afterAll hooks run before suites drain asynchronous heartbeats.
|
||||||
// Cleanup at worker exit, after all suite teardown, avoids deleting live state.
|
// Cleanup at worker exit, after all suite teardown, avoids deleting live state.
|
||||||
process.once("exit", () => fs.rmSync(paperclipTestHome, { recursive: true, force: true, maxRetries: 8, retryDelay: 50 }));
|
process.once("exit", () => {
|
||||||
|
restoreDirectoryWriteAccess(paperclipTestHome);
|
||||||
|
fs.rmSync(paperclipTestHome, { recursive: true, force: true, maxRetries: 8, retryDelay: 50 });
|
||||||
|
});
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
const SupertestTest = require("supertest/lib/test.js") as SupertestTestConstructor;
|
const SupertestTest = require("supertest/lib/test.js") as SupertestTestConstructor;
|
||||||
|
|||||||
Reference in new issue
Block a user