chore: Wait for pending NAPI invokes before cleaning up test fixtures - #356
Open
Ziinc wants to merge 1 commit into
Open
chore: Wait for pending NAPI invokes before cleaning up test fixtures#356Ziinc wants to merge 1 commit into
Ziinc wants to merge 1 commit into
Conversation
Fixture-copy directories were being removed in afterAll once all tests in a file finished, but nothing waited for the underlying invoke() calls to actually settle first. A component's untracked background fetch (e.g. the workspace sidebar's status poll) can still be reading a repo's local.db after its test finishes, so deleting the directory too early makes that call reject with an "unable to open database file" error nothing catches anymore -- an unhandled rejection (seen in discard-changes.test.tsx). Track pending invoke() calls in the test harness and drain them before cleanup removes the directories.
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.
Summary
This PR fixes a race condition in integration tests where fixture directories were being deleted while asynchronous NAPI
invoke()calls were still in flight, causing unhandled rejection errors.Key Changes
pendingInvokescounter andwaitForPendingInvokes()function to track in-flight NAPI calls intest/setup.integration.tsinvoke()function to increment/decrement the pending counter and notify when all calls settleafterAll()cleanup intest/utils.tsxto wait for all pending invokes to complete before deleting fixture directoriesImplementation Details
onAllSettled) allows cleanup code to be notified when the pending count reaches zerowaitForPendingInvokes()function includes a 5-second timeout to prevent tests from hanging indefinitelyhttps://claude.ai/code/session_01R26mLwvqdKS9chdR9iDmQZ