openclaw/scripts/tests
Bảo Võ 184cdd4eff
test(update): preserve unverified restart outcomes after package swaps (#142102)
* fix(update): keep a managed update from stranding the gateway after the install swap

A managed package update stages the new version, swaps it over the live
install root, and only then restarts and verifies the gateway. That
restart runs inside the updater process, which is still executing the
build that was just replaced. The bundled dist is split into
content-hashed chunks, so any `import()` reached for the first time after
the swap resolves to a chunk name that only the old tree contained:

  Gateway: restart failed: Error: ENOENT: no such file or directory,
  open '.../node_modules/openclaw/dist/shared-DFJEouXv.js'

`maybeRestartService` caught that as a restart failure, which became
`recovery.serviceRestartSafe: false`, which made the update helper exit
with the unsafe code and log "keep the gateway stopped until the
installation is repaired". The installation was fine -- npm install, the
swap, and doctor had all exited 0 -- but the gateway stayed down until
someone restarted it by hand. Observed on a 2026.9.1 -> 2026.9.2 npm
update: a 3h outage from a successful upgrade.

Two changes:

- Warm the restart path's lazy modules in `beforeActivate`, the last
  point where this process can still read its own install tree. The probe
  gained a loader for `gateway/call.js`, which was a bare dynamic import
  and so could not be warmed.

- Recognize a missing module inside our own install root and stop
  treating it as a verdict on the new install. Restarting the service is
  strictly better than parking it: the old process is gone either way,
  and a genuinely broken install still surfaces through the service's own
  supervision. A missing *data* file in the install root is still a real
  failure.

Claude-Session: https://claude.ai/code/session_01WKVaMWLzdHNJCa82nnTfWg

* test(update): use canonical normalization in restart regression

* test(update): register package-swap regression in its CI owner

* test(gateway): join task events before reset fixture cleanup

* test(gateway): join task events before in-test settlement

* test(gateway): prepare auth command runtime before handshake

* fix(ci): bound serial storage-state test stripes

* fix(ci): scope storage file ceiling to hosted jobs

* test(transcripts): wait for routed provider startup

* test: honor delivery and session fixture ownership

* test(transcripts): join configured provider startup

---------

Co-authored-by: baovo15 <duybao.vin@gmail.com>
Co-authored-by: Jason (Json) <263060202+fuller-stack-dev@users.noreply.github.com>
2026-09-19 22:50:18 -06:00
..
update-restart-module-outcome.mjs
update-restart-swap-fixture.mjs