Commit 856363c
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 856363c
1 file changed
Lines changed: 26 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 | + | |
89 | 110 | | |
90 | | - | |
| 111 | + | |
91 | 112 | | |
92 | 113 | | |
93 | 114 | | |
| |||
98 | 119 | | |
99 | 120 | | |
100 | 121 | | |
101 | | - | |
| 122 | + | |
102 | 123 | | |
103 | 124 | | |
104 | 125 | | |
| |||
115 | 136 | | |
116 | 137 | | |
117 | 138 | | |
| 139 | + | |
| 140 | + | |
118 | 141 | | |
119 | 142 | | |
120 | 143 | | |
| |||
0 commit comments