Repository navigation
test(main): deflake worktree-watch non-ENOENT readdir test with atomic EACCES injection - #10261
Merged
Merged
Conversation
…c EACCES injection
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated the worktree watcher regression test to replace directory-to-file swapping with permission revocation using 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…c EACCES injection (stablyai#10261)
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
Deflakes
worktree-git-common-watch.test.ts > does not fabricate worktree deletions when the readdir fails non-ENOENT (transient), which failedverifyon #9970's CI run (failed job) and passed on rerun.The race
The test simulated a non-ENOENT readdir failure by replacing the worktrees dir with a file (
rmSync+writeFileSync), reasoning that a synchronous swap leaves no event-loop turn to observe the transient ENOENT window. That reasoning misses libuv threadpool concurrency: an in-flight poll tick's asyncopendirexecutes on a worker thread and can land in the wall-clock window between the two sync calls. It then legitimately observes ENOENT (dir gone = all worktrees removed) and emits exactly thedelete keep+update worktreesevents seen in the CI failure.There is no atomic way to replace a non-empty directory with a file, so the window cannot be closed by reordering.
The fix
Inject the failure with
chmodSync(worktreesDir, 0o000)instead — one atomic syscall, zero ENOENT window. A concurrentopendirobserves either success or EACCES, never ENOENT, and EACCES exercises the same retain-previous-entries branch insnapshotGitCommonthat the test protects. Gated withit.runIfoff Windows and root, where chmod 0 cannot revoke directory listing and the injection would be inert.Validation
worktree-git-common-snapshot.tstemporarily broken (old catch-all behavior), the reworked test fails — it still catches the regression it exists for.tsc --noEmit -p config/tsconfig.node.jsonclean; oxlint clean.Notes
process.getuid?.()optional-chaining keeps the gate expression portable on Windows, where the API is absent.