Repository navigation
Commit 1ad131a
authored
fix(update): stage, verify, and swap npm self-updates with rollback (#2079)
* fix(update): stage, verify, and swap npm self-updates with rollback
The npm self-update installed straight into the live global tree, so any
failure after npm removed the old files left a file-less package skeleton
with no recovery (#1849) and nothing verified the new tree before it went
live (#1942). The launcher now stages the target version into a sibling
directory (npm --prefix, same volume), verifies a manifest inside the stage
(package.json version, launcher integrity, sentinel deps), moves live aside
to a sibling backup, swaps the staged tree in, re-verifies, and rolls back by
reverse rename on failure — writing a recovery marker with a one-line restore
on double fault. A boot probe restores the newest backup over a broken live
tree (power loss mid-swap) and reaps stale backups once live verifies.
Staging and backup are SIBLINGS of the package dir, never children — a child
would travel with the live rename and the live tree cannot move into its own
subtree (design defect caught by the plan audit and fixed here).
Closes #1942
Closes #1849
* fix(update): harden transactional swap per adversarial review
- verify the bundled Bun binary by size (>=10MB), not just its package.json,
so the boot probe can never call a Bun-less tree healthy and reap the only
backup
- bounded EPERM/EBUSY/EACCES rename retry for the Windows AV/indexer class
- staging/backup mkdir failures return phase errors with live untouched; an
unexpected throw now reports and stops instead of falling back to the
destructive in-place install
- the Windows service wrapper (outside the package tree) restores the newest
.ocx-backup-* sibling before declaring the install incomplete — the exact
power-loss window the in-launcher probe cannot reach1 parent 11e03eb commit 1ad131a
6 files changed
Lines changed: 534 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
267 | 268 | | |
268 | 269 | | |
269 | 270 | | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 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 | + | |
277 | 315 | | |
278 | 316 | | |
279 | 317 | | |
| |||
449 | 487 | | |
450 | 488 | | |
451 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
452 | 504 | | |
453 | 505 | | |
454 | 506 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1535 | 1535 | | |
1536 | 1536 | | |
1537 | 1537 | | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
1538 | 1541 | | |
1539 | 1542 | | |
1540 | 1543 | | |
| |||
1547 | 1550 | | |
1548 | 1551 | | |
1549 | 1552 | | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
1550 | 1556 | | |
1551 | 1557 | | |
1552 | 1558 | | |
1553 | 1559 | | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
1554 | 1563 | | |
1555 | 1564 | | |
1556 | 1565 | | |
| |||
1563 | 1572 | | |
1564 | 1573 | | |
1565 | 1574 | | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
1566 | 1595 | | |
1567 | 1596 | | |
1568 | 1597 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
0 commit comments