fix(coding-agent): stop RpcClient skipping listeners on unsubscribe

closes #9990
This commit is contained in:
David Brailovsky 2026-09-25 11:26:14 +02:00
parent f444ea5eaf
commit 92e8d4f02a
2 changed files with 4 additions and 2 deletions

View file

@ -15,6 +15,7 @@
- Fixed X11 clipboard text being misidentified as an image when the clipboard owner accepts unadvertised image targets ([#9786](https://github.com/earendil-works/pi/issues/9786)).
- Prevented managed git packages from automatically installing Pi peer dependencies and added warnings for extension packages that list host-provided modules in `dependencies` ([#9863](https://github.com/earendil-works/pi/issues/9863)).
- Fixed pinned git extensions loaded with `-e` continuing to use the first downloaded commit after the ref changes ([#9982](https://github.com/earendil-works/pi/issues/9982)).
- Fixed `RpcClient` skipping the next event listener when a listener unsubscribes while handling an event, which could make `waitForIdle()` time out after `collectEvents()` ([#9990](https://github.com/earendil-works/pi/issues/9990)).
## [0.87.1] - 2026-09-22

View file

@ -525,8 +525,9 @@ export class RpcClient {
return;
}
// Otherwise it's an event
for (const listener of this.eventListeners) {
// Otherwise it's an event. Iterate a snapshot so listeners that unsubscribe during dispatch
// do not cause later listeners to miss this event.
for (const listener of [...this.eventListeners]) {
listener(data as JsonAgentSessionEvent);
}
} catch {