Commit e184720
committed
perf(run-events): unblock bus dispatch with runFork in subscriber callbacks
Bus.subscribeCallback wraps the callback's return value in
Effect.tryPromise(() => Promise.resolve().then(() => callback(msg)))
inside a runForEach loop, so a Promise-returning callback (such as
Effect.runPromise) serializes handler completion per subscription —
each descendant question/permission event waits for the previous
handler's reject/reply round trip before dispatch advances.
Replace Effect.runPromise with Effect.runFork. runFork returns a
Fiber synchronously (non-thenable), so the bus's tryPromise resolves
immediately and the next event dispatches without waiting. Handler
defects no longer surface through Bus.on's tryPromise.catch, so wrap
the forked effect with Effect.tapCause + log.error.
Drops the per-event Promise wrapper allocation and unblocks
concurrent dispatch for long-running subagent loops with many
simultaneous descendants.
Addresses audit finding F7 (Opus diamond review, 2026-04-22).1 parent 379dbf4 commit e184720
2 files changed
Lines changed: 90 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
89 | 125 | | |
90 | | - | |
| 126 | + | |
91 | 127 | | |
92 | 128 | | |
93 | 129 | | |
| |||
98 | 134 | | |
99 | 135 | | |
100 | 136 | | |
101 | | - | |
| 137 | + | |
102 | 138 | | |
103 | 139 | | |
104 | 140 | | |
| |||
113 | 149 | | |
114 | 150 | | |
115 | 151 | | |
| 152 | + | |
116 | 153 | | |
117 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
118 | 159 | | |
119 | 160 | | |
120 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
523 | 523 | | |
524 | 524 | | |
525 | 525 | | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
526 | 572 | | |
0 commit comments