Problem
.aiox-core/core/config/config-cache.js starts a module-level setInterval (60s sweep) at require-time. The timer is unref()'d (so it doesn't hang the process), but under Jest it keeps firing after a test file's suite finishes and after Jest tears down the test environment. When the sweep lands mid-teardown with AIOX_DEBUG logging (or any future log in that callback), Jest throws:
Cannot log after tests are done
The failure is intermittent — it depends on whether the 60s sweep lands inside a suite's window — which makes it a classic flaky-CI source. We hit it on a downstream fork's CI (run 28661638857-equivalent) and had to patch locally.
Fix that works (running on our fork)
Skip the timer entirely in Jest workers — JEST_WORKER_ID is set by every Jest worker process; CLI/runtime processes are unaffected:
if (!process.env.JEST_WORKER_ID) {
const cacheCleanupTimer = setInterval(() => {
const cleared = globalConfigCache.clearExpired();
if (cleared > 0 && process.env.AIOX_DEBUG) {
console.log(`🗑️ Config cache: Cleared ${cleared} expired entries`);
}
}, 60 * 1000);
if (typeof cacheCleanupTimer.unref === 'function') {
cacheCleanupTimer.unref();
}
}
Happy to send this as a PR if useful.
🤖 Generated with Claude Code
Problem
.aiox-core/core/config/config-cache.jsstarts a module-levelsetInterval(60s sweep) at require-time. The timer isunref()'d (so it doesn't hang the process), but under Jest it keeps firing after a test file's suite finishes and after Jest tears down the test environment. When the sweep lands mid-teardown withAIOX_DEBUGlogging (or any future log in that callback), Jest throws:The failure is intermittent — it depends on whether the 60s sweep lands inside a suite's window — which makes it a classic flaky-CI source. We hit it on a downstream fork's CI (run 28661638857-equivalent) and had to patch locally.
Fix that works (running on our fork)
Skip the timer entirely in Jest workers —
JEST_WORKER_IDis set by every Jest worker process; CLI/runtime processes are unaffected:Happy to send this as a PR if useful.
🤖 Generated with Claude Code