Commit 4936b05
fix(sdk): address PR #936 review feedback
EventBus.addListener — stale-closure bug (CodeRabbit + Codex P1):
the unsubscribe returned by `addListener` captured `set` by reference.
After unsubscribing, registering a new handler for the same event, and
calling the original `off` again, the closure would observe the stale
(empty) `Set` and call `this.handlers.delete(event)` — silently dropping
every fresh listener for that event.
Fix: re-read the current Set from `this.handlers` inside the closure
and bail out if it isn't the one we originally inserted. `removeListener`
already had this shape; bringing `addListener`'s unsubscribe in line.
Regression test added — covers off()→addListener→off() →
new listener must still be called on emit.
spawn-reviewers script — `agentExited` handler had a stray `code?: number`
second parameter that's always undefined under the new single-arg
listener contract. Read `agent.exitCode` from the Agent payload instead,
matching the pattern in `packages/openclaw/src/spawn/process.ts`.
CHANGELOG — split the single long `@agent-relay/sdk` breaking-change
bullet into three impact-first bullets (listener API migration,
channel-event payload shape change, new lifecycle hooks) per the repo's
changelog-style rule.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent d67c9af commit 4936b05
4 files changed
Lines changed: 30 additions & 5 deletions
File tree
- packages/sdk/src
- __tests__
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
55 | 71 | | |
56 | 72 | | |
57 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
40 | 47 | | |
41 | 48 | | |
42 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
0 commit comments