Fix Vitest Windows CI EPERM Hang - #2
Open
skoll43 wants to merge 4 commits into
Open
Conversation
A churned org's bridge kept firing a POST on every single event forever —
the 402 ("Subscription required") response fell through the status handling
(only 401 and 429 were handled) and the fire-and-forget caller never backed
off.
Now a 402 persists `suppressed_until` (epoch ms, now + 24h) into
platform.json — the same config file the bridge already owns — and prints
one concise stderr note. maybeForward gates on the marker BEFORE any network
call; an expired marker is cleared and forwarding resumes automatically, and
any 2xx response clears a lingering marker for immediate resume after
reactivation. Marker survives restarts and is shared across concurrent
sessions via the config file; in-flight 402 bursts dedupe to a single write
and note.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Billing enforcement belongs to the platform side only. The server already rejects churned-org forwards with 402 before any handler or D1 write runs; the OSS bridge must stay billing-agnostic. This reverts commit c94e8fc. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Vitest
kill EPERMHang on Windows (Leaky File Locks)Problem
On Windows environments, the CI and local
npm testruns frequently hang at the very end of the test suite during the Vitest worker teardown phase, throwing akill EPERMorTimeout terminating forks workererror.While the majority of the codebase correctly uses in-memory databases (
:memory:) or explicitstore.cleanup()hooks, several integration test files were instantiating file-backedSessionDBandContentStoreinstances (better-sqlite3) locally withintest()blocks and never closing them.Because Vitest runs in a worker pool, these unclosed C++ native file locks persist at the OS level. When Vitest attempts to terminate the worker pool, Windows rejects the termination or directory cleanup due to the active locks, causing the deadlock.
Solution
Introduced a scope-safe teardown pattern to the 5 anomalous test files:
tests/core/search-project-filter.test.tstests/integration/omp-plugin.test.tstests/integration/commit-message-symmetry.test.tstests/integration/cross-project-attribution.test.tstests/integration/seed-parity-coverage.test.tsPattern:
Added a module-level tracking array (
const activeDBs = []) to each file. Instances are pushed to the array upon creation, and anafterEach()hook iterates through the array to forcefully call.close()(and.cleanup()) on every instance before clearing the array.Verification
search-project-filter.test.ts) in isolation now tears down instantly (~2 seconds) on Windows without hanging.afterEachhook guarantees closure even if the test fails or times out.