fix(qa): recheck Matrix sync events after poll · openclaw/openclaw@698f154
steipete
·
2026-04-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -144,7 +144,7 @@ export function createMatrixQaRoomObserver(
|
144 | 144 | const startSince = await this.prime(); |
145 | 145 | const startedAt = Date.now(); |
146 | 146 | let cursorIndex = roomObserver.cursorIndex; |
147 | | -while (Date.now() - startedAt < waitParams.timeoutMs) { |
| 147 | +while (true) { |
148 | 148 | const matched = findMatrixQaObservedEventMatch({ |
149 | 149 | cursorIndex, |
150 | 150 | events: roomObserver.events, |
@@ -160,20 +160,24 @@ export function createMatrixQaRoomObserver(
|
160 | 160 | }; |
161 | 161 | } |
162 | 162 | |
| 163 | +const elapsedMs = Date.now() - startedAt; |
| 164 | +if (elapsedMs >= waitParams.timeoutMs) { |
| 165 | +roomObserver.cursorIndex = Math.max(roomObserver.cursorIndex, cursorIndex); |
| 166 | +return { |
| 167 | +matched: false, |
| 168 | +since: roomObserver.since ?? startSince, |
| 169 | +}; |
| 170 | +} |
| 171 | + |
163 | 172 | cursorIndex = roomObserver.events.length; |
164 | | -const remainingMs = Math.max(1_000, waitParams.timeoutMs - (Date.now() - startedAt)); |
| 173 | +const remainingMs = Math.max(1_000, waitParams.timeoutMs - elapsedMs); |
165 | 174 | await pollMatrixQaRoomObserver({ |
166 | 175 | ...params, |
167 | 176 | observedEvents: params.observedEvents, |
168 | 177 | roomObserver, |
169 | 178 | timeoutMs: remainingMs, |
170 | 179 | }); |
171 | 180 | } |
172 | | -roomObserver.cursorIndex = Math.max(roomObserver.cursorIndex, cursorIndex); |
173 | | -return { |
174 | | -matched: false, |
175 | | -since: roomObserver.since ?? startSince, |
176 | | -}; |
177 | 181 | }, |
178 | 182 | async waitForRoomEvent(waitParams) { |
179 | 183 | const result = await this.waitForOptionalRoomEvent(waitParams); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。