Repository navigation
Commit 9c24106
committed
fix(task-persistence): report the read failure when missing-file recovery rejects
readFileWithMissingRetry awaited recoverMissingJsonFile inside its retry catch but
outside any handler, so a rejection from the recovery escaped the function instead of
becoming the value that branch interprets. Every caller classifies this read by error
code: apiMessages.ts maps ENOENT to "no file yet" and anything else to io_error,
taskMessages.ts maps it to the "not_found" kind, TaskHistoryStore.ts swallows it into
null. A rejecting recovery therefore re-classifies the read: an EBUSY inside recovery
becomes an I/O error on a file that is merely absent. The fix keeps the missing-file
retry the rows already assert and counts a rejected recovery as "nothing recovered", so
the caller always receives the ENOENT read failure it knows how to classify.
jsonFileRecovery traces the recovery failure with its own code before throwing, so the
diagnostic is not lost, and no new abstraction is introduced.
safeWriteJson.ts:343 is a changed executable line in this pull's own diff: the hunk
switches its argument from absoluteFilePath to resolvedTargetPath, and no row
distinguished the two spellings because every existing recovery row keeps the alias and
the referent in one directory. The added row plants the orphaned backup beside the
referent with the alias directory empty, which only the resolved-target spelling can
see, and asserts that the merge callback read the restored history, that the trace
reported the restore, that the published file holds the merged content, and that the
backup was consumed. The link is simulated by mocking fs.realpath, the same way the
staging and lock-key rows in that file do, because real symlinks are unavailable here.
Controls, holding the previous head d6fa711:
- new retry row against the previous head with the source untouched: 1 failed | 3
passed, the failure being the escaping EBUSY rejection; with the fix: 4 passed.
- the same row against each mutant the instrument plans for lines 54-55 of the fix:
a recovery rejection counted as recovered (.catch(() => true)) makes the reader
resolve with bytes that appeared during the recovery and fails this row alone;
reverting line 49 to its pre-fix shape fails this row alone.
- new recovery row with 343 reverted to its pre-pull argument: the only failure in
utils/__tests__/safeWriteJson.test.ts (1 failed | 53 passed | 4 skipped), so the row
reaches 343 and asserts exactly the change this pull made there.
- repo-wide prettier --check .: clean. tsc --noEmit in src: clean. eslint on the three
touched files with --max-warnings=0 --prune-suppressions: no problems, and
src/eslint-suppressions.json is byte-identical to its committed blob (a prune run on
a partial file set rewrites that file, so it was reverted).
Pricing, printed by scripts/stryker-diff.mjs (blob c332971815aecfaf) against this
pull's own base 5319fe9: the instrument reports
"extension has 770 changed executable lines (limit 500)" at the previous head and 772
here, so this commit adds two chargeable executable lines to a package already 270
lines over the cap, and 2357 stays a split question - this fix does not pretend
otherwise. On its own unit delta the instrument lists only
core/task-persistence/readFileWithMissingRetry.ts:54-55 (2 chargeable lines) and its
dry run instrumented that file with 5 mutants (limit 400): the two added rows are
test-only and the instrument's own path classifier excludes __tests__ paths, so the
rows are cap-neutral by construction rather than by headroom.
Review thread answered: pull-request comment 4505288199, on src/utils/safeWriteJson.ts
line 343. The await above has no review thread to answer: the thread listing read from
this repository tonight lists 50 threads, every one of them resolved, and none on
src/core/task-persistence/readFileWithMissingRetry.ts.
No changeset and no changelog entry.1 parent d6fa711 commit 9c24106
3 files changed
Lines changed: 93 additions & 1 deletion
File tree
- src
- core/task-persistence
- __tests__
- utils/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
29 | 69 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1315 | 1315 | | |
1316 | 1316 | | |
1317 | 1317 | | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
1318 | 1364 | | |
0 commit comments