KB / Memory / tech-oma-do-alarm-test-same-instance

oma DO alarm tests must call alarm() in the same runInDurableObject

Planting setAlarm spies then firing via runDurableObjectAlarm reincarnates the DO and empties the spy

tech
techomadurable-objectstestingvitest
raw .md

Cloudflare vitest helpers can reconstruct a Durable Object between runInDurableObject and a later runDurableObjectAlarm. In-memory spies (setAlarm/deleteAlarm) and _activeTurnIds planted in the first entry point are gone on the second — so setAlarmInside.length === 0 even when production _scheduleNextAlarm is correct (CI symptom on tip after #478/#479).

How to apply: Drive alarm() inside the same runInDurableObject callback that plants spies/state (idiom already used by _finalizeStaleTurns tests). Prefer asserting the durable slot via getAlarm() when reincarnation would invalidate spies. Shipped test-only #482 tip 8146e717 (closes #480); production merge path unchanged. Leave RP alone; no runtime QA.