@try-works/dsh-memory 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/host.js +11 -2
package/package.json
CHANGED
package/src/host.js
CHANGED
|
@@ -759,8 +759,17 @@ export function wireHost(ctx, store, cfg) {
|
|
|
759
759
|
|
|
760
760
|
// session lifecycle: associate workspace + capture on turn end
|
|
761
761
|
ctx.on('session/event', (session, event) => {
|
|
762
|
-
|
|
763
|
-
|
|
762
|
+
// DEFERRED, and it has to be. This handler runs INSIDE an append - the harness sets a reentrancy
|
|
763
|
+
// flag for the duration of the session/event emission - and Session.append refuses to reenter:
|
|
764
|
+
// "session append cannot reenter while another append is being published". Measured in the live
|
|
765
|
+
// log, exactly half the publishes failed with that message while the pre-step ones succeeded.
|
|
766
|
+
// A macrotask lands after the append has settled, so the guard is satisfied.
|
|
767
|
+
if (event.type === 'turn/start') {
|
|
768
|
+
void resolveKey(session).then(() => setTimeout(() => publishMemoryMap(session), 0))
|
|
769
|
+
} else if (event.type === 'turn/end') {
|
|
770
|
+
maybeCapture(session)
|
|
771
|
+
setTimeout(() => publishMemoryMap(session), 0)
|
|
772
|
+
}
|
|
764
773
|
})
|
|
765
774
|
|
|
766
775
|
// Disposal is the LAST chance to capture a session, so it bypasses the throttle.
|