Skip to content

Reject emitted promises on error#1954

Open
fallintoplace wants to merge 1 commit into
openai:mainfrom
fallintoplace:fix/event-emitter-error-promise
Open

Reject emitted promises on error#1954
fallintoplace wants to merge 1 commit into
openai:mainfrom
fallintoplace:fix/event-emitter-error-promise

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

Summary

  • Make EventEmitter.emitted(event) reject when error is emitted before the requested event.
  • Keep emitted('error') resolving with the error value.
  • Remove the opposite one-time listener after either resolution or rejection.
  • Add coverage for both core and lib EventEmitter implementations.

Why

The docstring promised that emitted() rejects on error, but the implementation only listened for the requested event. Code awaiting a message-like event could hang forever if an error arrived first.

Validation

  • ./node_modules/.bin/jest tests/EventEmitter.test.ts --runInBand
  • ./node_modules/.bin/prettier --check src/lib/EventEmitter.ts src/core/EventEmitter.ts tests/EventEmitter.test.ts
  • ./node_modules/.bin/eslint src/lib/EventEmitter.ts src/core/EventEmitter.ts tests/EventEmitter.test.ts
  • ./node_modules/typescript/bin/tsc
  • ./scripts/build

@fallintoplace fallintoplace requested a review from a team as a code owner June 23, 2026 19:04
@HAYDEN-OAI HAYDEN-OAI added the upstream Needs to be addressed in Stainless upstream label Jun 23, 2026 — with ChatGPT Codex Connector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream Needs to be addressed in Stainless upstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants