Repository navigation
Commit 66a7e40
test(timeline): pin the refused directory fsync (#3304)
Fixes #3301
Owner: Dev
Written-by: Dev
Reviewer: Reviewer
Docs-not-needed: tests only; no product behaviour and no documented
write order changes.
## What this is
The fix is already in `main`: `#3300` (merged as `1d06764b`) made
`flushDirectory` tolerate a refused directory `fsync` — EPERM on
Windows, EINVAL on a filesystem without directory flushes — so a segment
that was synced and renamed is not rewritten on every flush. This branch
is rebased onto `main` (`664f48fd`); the old tip's `src/store.js` change
and `changelog.d/3301.fixed.md` are gone. The diff is one file:
`plugins/timeline/test/store.test.js`.
`main` has no `sync` option to inject a refusal, so the cases pin the
`fsyncSync` binding `store.js` imports with `node:module`'s
`syncBuiltinESMExports()` — the seam the repo already uses in
`ds-bot/test/store.test.js`. Only directory handles are refused: the
file sync stays real, so the cases cannot paper over a failing file
sync.
## What the three cases pin
1. **EPERM still saves** — `flush()` is true, `stats().failing` is
false, the segment is not rewritten by the next flush, and the records
read back after a reopen.
2. **EINVAL tolerated** — the same answer for a filesystem without
directory flushes.
3. **Rotation under refusal** — the cap still prunes to
`trace-000002.json`/`trace-000003.json` and the surviving records are
`[3, 4, 5, 6]`.
Red first, same tree with only `noDirectoryFlush` emptied (`new
Set([])`; src restored afterwards): `node --test test/store.test.js` →
16 pass / 3 fail, exactly the three cases above.
## Ran at this tip:
```
$ cd plugins/timeline && TZ=UTC npm test
# tests 175 / pass 175 / fail 0 (main before this change: 172/172)
$ TZ=UTC node --import ./test/resolve.mjs --test test/store.test.js
# tests 19 / pass 19 / fail 0
$ node scripts/lint-plugins.mjs timeline
# 0 errors, 9 pre-existing warnings
$ node .github/scripts/changelog.mjs check
# 4 fragment(s) well formed
```
Not run: real Windows (the refusal is Windows-only; the cases inject
it), arch-docs (`core/scripts/check-arch-docs.mjs` shells out to `git`,
absent here; the commit carries `Docs-not-needed:`), full `npm run
verify`, and CI's Node 24 leg.
## Checkpoint
<!-- flybot:checkpoint -->
{
"pr": 3304,
"claim": "Dev",
"issue": 3301,
"summary": "Rebased onto main 664f48f with the implementation dropped:
#3300 already tolerates a refused directory fsync, so the diff is one
test file. Three cases pin it by refusing only directory handles through
the fsyncSync binding store.js imports: EPERM still saves the segment
and it is not rewritten, EINVAL is tolerated the same way, and a
rotation still prunes to the cap. Emptying the tolerated set turns all
three red.",
"files": [
"plugins/timeline/test/store.test.js"
],
"checks": {
"ran": "cd plugins/timeline && TZ=UTC npm test; TZ=UTC node --import
./test/resolve.mjs --test test/store.test.js; node
scripts/lint-plugins.mjs timeline; node .github/scripts/changelog.mjs
check",
"result": "green",
"at": "c4940e7977d0edc75a9167258a84ad9d6500a636"
},
"next": "none — ready for review"
}
<!-- /flybot:checkpoint -->
Co-authored-by: Danyang Chen <birfychen@gmail.com>1 parent 664f48f commit 66a7e40
1 file changed
Lines changed: 70 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
277 | 279 | | |
278 | 280 | | |
279 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
0 commit comments