Fix 8 semantic bugs in a hand-rolled Node.js event emitter (re-entrancy, once/off, error events, leak warning)
Exact prompt
# Task: fix the plugin host's event emitter `emitter.js` (Node 20, CommonJS, no dependencies) has several bugs reported by plugin authors. Fix them so it behaves as follows: 1. `emit` calls the listeners registered at the moment `emit` starts, in registration order, even if listeners add or remove listeners during the emit (removals/additions affect only later emits). 2. `once(ev, fn)` listeners run at most once even if the event is emitted again from inside the listener (re-entrant emit), and `off(ev, fn)` with the original `fn` removes a pending `once` listener. 3. `emit` returns `true` if there was at least one listener, else `false` (also when the listener list exists but is empty). 4. Emitting `'error'` with no `'error'` listener throws the error argument (or `new Error('Unhandled error')` if none was given); with a listener it is just delivered. 5. A listener that throws stops the emit and the error propagates to the `emit` caller, but `once` listeners that threw are still removed. 6. The leak warning is printed at most once per event name, when the count first exceeds the max; `setMaxListeners(0)` disables it. 7. `off` removes only the most recently added matching registration when the same function was added twice. 8. `on`, `once`, `off`, `setMaxListeners` return `this`; `listenerCount` counts pending once listeners. Keep the export shape. Add your own tests under `test/` if you want (`node --test test/`). No network, no npm installs.
Mirrors real node:events semantics: snapshot iteration, re-entrant once, removing a once wrapper by its original function, throw-on-unhandled 'error', removing the last duplicate registration; each is a separate hidden test. Original benchmark task written for usecaserank.com (not based on a specific public post). Headless, offline run on a reproducible fixture. Each run's notes say how its cost was measured (estimates are marked).
Success criteria: 1. hidden_tests_pass: all 11 hidden node:test tests pass (node 20, 60 s cap). 2. own_tests_pass_or_absent: if the agent added tests under test/, `node --test test/` exits 0.
Best model for this task so far: Claude Haiku 5.5 (effort default (no --effort flag) · thinking on) (success, $0.0079, 33s).
All runs (4)
100% pass rate across 4 eligible runs: 4 pass, 0 partial, 0 fail. Partial and failed runs are listed below with everything else.ⓘ
| Model | Cost | Time | Step-insⓘ | Autonomy | Outcome | Trustⓘ | Date | Compare |
|---|---|---|---|---|---|---|---|---|
| OGPT-6.1 Soldefault · thinking on | $0.06 | 1m | 0 | Fully autonomous | pass | Trust 80% | 2026-10-22 | |
| AClaude Haiku 5.5default · thinking on | $0.0079 | 33s | 0 | Fully autonomous | pass | Trust 80% | 2026-10-17 | |
| AClaude Opus 5.5default · thinking on | $0.19 | 19m | 0 | Fully autonomous | pass | Trust 80% | 2026-10-17 | |
| AClaude Sonnet 5.5default · thinking on | $0.07 | 18s | 0 | Fully autonomous | pass | Trust 80% | 2026-10-17 |
Embed this result
A live badge for this use case. It links back here and updates as new runs are published.
Get new runs and ranking changes weekly
Which models got better or cheaper on real tasks like this one.