mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-07 08:33:50 +08:00
When a 'newListener' listener threw while events.once registered its listeners, the exception escaped the call, the 'error' listener's closure was never registered or released, and the shared state and its promise leaked with it. Node registers both listeners inside the promise's executor: the throw rejects the returned promise, and the listener whose announcement threw is not added (the event's listener stays when only the 'error' announcement throws). scr_events_once now takes the pending exception, takes back the listener whose announcement threw without a 'removeListener' event, releases the 'error' closure when it was never registered, and rejects the promise with the exception.