mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-22 10:25:20 -06:00
e294c154a6
`server.sessions.compaction-read-errors` captured the real transcript reader as a side effect of its `vi.mock` factory and consumed it in `beforeEach`. Vitest runs a factory on first import of the mocked module, and the gateway-server project is `isolate: false`, so on a warm module graph the factory can still be unrun when the hook fires. Run 32335933003 hit that on `main`: all five tests failed with `transcript reader mock was not initialized` while the same 24-file shard passes locally in the same order. Resolve the real implementations with `vi.importActual` at use time instead, so there is no state that can be observed before it is written. Applies the same repair to the two siblings sharing the invariant: `server.sessions.create` (which had worked around it by force-importing both mocked modules in `beforeAll`) and `client-voice-session` (whose `beforeEach` silently skipped installing the real append when the capture was missing). `tools.optional` keeps its guard: it evaluates inside the mock implementation, so the factory has necessarily run by then.