Skip to content

Commit 97fe90a

Browse files
committed
fix: stabilize flaky AI snapshot tests
Two root causes identified and fixed: 1. expectFileDeleted used file.exists() which checks the _stat cache. After unlink, _handleDirectoryChange re-reads the parent dir and can repopulate _stat on the deleted File object from a racing readdir. Switch to FileSystem.existsAsync() which bypasses the cached _stat and goes directly to the impl. 2. _createOrUpdateFile could fail with NotFound when file.exists() returned stale true after a delete+recreate cycle. Add fallback: if getDocumentForPath fails, create the file on disk and retry.
1 parent 13b5e58 commit 97fe90a

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

test/spec/ai-snapshot-test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,10 @@ define(function (require, exports, module) {
133133
}
134134

135135
async function fileExists(name) {
136-
return new Promise(function (resolve) {
137-
const file = FileSystem.getFileForPath(toVfsPath(name));
138-
file.exists(function (err, exists) {
139-
resolve(exists);
140-
});
141-
});
136+
// Use FileSystem.existsAsync which bypasses the cached _stat on
137+
// File objects — file.exists() can return stale true when
138+
// _handleDirectoryChange re-populates _stat from a racing readdir.
139+
return FileSystem.existsAsync(toVfsPath(name));
142140
}
143141

144142
async function expectFileDeleted(name) {

0 commit comments

Comments
 (0)