fix(core): metadata source walk skips cache dirs and vanished files - #928
Merged
Merged
Conversation
The walk over editor sources stats and reads files that concurrent suites (history.test.ts) create and delete under .turbo, failing quality on main with ENOENT. Extract the walk with an injectable fs and add a failing case that deletes a listed file mid-scan and plants a .turbo probe. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…walk Skip build, dependency, cache and dot directories (.turbo, .next, node_modules, dist, …) and treat ENOENT on readdir, stat or read as a file that vanished mid-walk, so concurrent suites can no longer fail quality. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
I hit an error while handling your request (Model unavailable on AI Gateway free tier: Free tier users do not have access to this model. Upgrade to paid credits at https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dtop-up for unrestricted…). Please try again, rephrase, or reach out if it keeps failing. Error id: daf35de7-e1eb-4dc3-9bdc-d90943e94c50 |
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.
What does this PR do?
This fixes the
qualityfailure that #923 introduced onmainata9c1d4561. The failure also reproduced on a rerun.Cause:
reference-inventory.test.tswalks every editor source file to find the metadata keys it uses. At the same time,history.test.tscreates and deletes.turbo/history-*/probe.ts. When a file the walk has already listed is deleted before it is stat'ed or read, the walk throwsENOENT.Changes:
contracts/metadata-scan.tsasscanMetadataSources. It takes an injectable fs so a test can reproduce the race. This file stays test and tooling only, excluded from the package build.node_modules,dist,build,out,coverage,__fixtures__and every dot-directory (.turbo,.next, …).ENOENTfrom readdir, stat or read is treated as a file that vanished mid-walk and is skipped. Any other error still throws.Commits:
79909befaadds the reproducing test. It deletes a listed file between readdir and stat, and plants a.turbo/history-1/probe.ts. On that commit the test fails withENOENT: … stat …/vanishing.ts.How to test
bun run --cwd packages/core test: 2955 pass, 0 fail.bun run --cwd packages/core check-types: clean.bun run check: clean.Screenshots / screen recording
Not applicable: tests only.
Checklist
bun devsurface)bun checkto verify)mainbranch🤖 Generated with Claude Code
Note
Low Risk
Changes are limited to contract/test tooling in
metadata-scan.tsand inventory tests; no runtime editor or package build surface.Overview
Fixes flaky
qualityfailures whenreference-inventory.test.tswalks editor sources while other suites delete files under.turbo.The inline source-tree walk is replaced by
scanMetadataSourcesinmetadata-scan.ts, which maps metadata keys to the first source file that uses them. The walk now ignores build/cache/dependency paths (dist,build,out,coverage, etc.) and all dot-directories (e.g..turbo), and treatsENOENTon readdir/stat/read as a file that disappeared mid-scan instead of throwing. Filesystem access is injectable viaScanFsso tests can simulate the race.reference-inventory.test.tsuses the shared scanner forMETADATA_KEYSand adds a test that deletes a listed file between readdir and stat while ensuring keys under.turboare not picked up.Reviewed by Cursor Bugbot for commit 3e13c78. Bugbot is set up for automated code reviews on this repo. Configure here.