Repository navigation
Commit 6536617
committed
fix(config): roll the settings cache back when a state write is rejected
Third CodeRabbit round (Persistence Integrity). `ContextProxy.updateGlobalState` wrote
the key into `stateCache` before `globalState.update` settled, so a rejected write left
an in-memory value that disk never received: readers, `export()`/`import()` and the next
restart all report a setting that does not exist. The cache now rolls the key back to
the value that is actually on disk and the rejection still reaches the caller; the
success path is unchanged, and `Memento.update` is normalized first because it is only
specified as a `Thenable` (removing that normalization breaks 46 tests that stub it as
a plain object).
This is the failure `exportSettings` can now report: it confirms the file it wrote and
says the location could not be remembered. Without the rollback, the next dialog would
still default to that unremembered location for the rest of the run.
Tests: 2 new in `core/config/__tests__/ContextProxy.spec.ts` (38/38). Six of seven
hand-written mutants over the new lines are killed (drop the rollback, roll back to
undefined, do not capture the previous value, swallow the rejection, skip the cache
write on success, drop the normalization); the seventh re-assigns the same value on
success and is equivalent. Full unit suite before and after: 58 failed / 11996 passed
before, 58 failed / 11998 passed after - the same 15 pre-existing Windows failures
(Zoo-Code-Org#2059 among them), no new ones. `eslint --max-warnings=0` exits 0 with unchanged
suppression counts for both files.1 parent bcd0822 commit 6536617
2 files changed
Lines changed: 38 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
| 368 | + | |
368 | 369 | | |
369 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
370 | 383 | | |
371 | 384 | | |
372 | 385 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
197 | 221 | | |
198 | 222 | | |
199 | 223 | | |
| |||
0 commit comments