fix: preserve event delivery across scheduler lifecycle boundaries

This commit is contained in:
Xipong
2026-09-09 02:24:01 +03:00
committed by Teknium
parent 42f2067092
commit 3fbc408ff6
2 changed files with 19 additions and 0 deletions
+17
View File
@@ -117,3 +117,20 @@ it('coalesces reconnects during a sweep into one fresh follow-up sweep', async (
await flush()
expect(mocks.getHermesConfigRecord).toHaveBeenCalledTimes(2)
})
it.each(['stop', 'disconnect'])('drops the queued sweep on %s', async action => {
let release!: (config: Record<string, unknown>) => void
mocks.getHermesConfigRecord.mockReturnValueOnce(new Promise(resolve => { release = resolve })).mockResolvedValue({ mcp_servers: {} })
startMcpHealthChecker()
mocks.gatewayState.set('open')
mocks.gatewayState.set('closed')
mocks.gatewayState.set('open')
if (action === 'stop') {stopMcpHealthChecker()}
else {mocks.gatewayState.set('closed')}
release({ mcp_servers: {} })
await flush()
await flush()
expect(mocks.getHermesConfigRecord).toHaveBeenCalledTimes(1)
})
+2
View File
@@ -175,6 +175,8 @@ function arm(): void {
}
function disarm(): void {
sweepQueued = false
if (timer !== null) {
clearInterval(timer)
timer = null