fix(audio): reject ffplay spawn errors#2012
Open
tylergibbs1 wants to merge 1 commit into
Open
Conversation
Listen for asynchronous child-process errors so playAudio() rejects when ffplay cannot be started instead of causing an uncaught EventEmitter error. Assisted-by: OpenAI Codex (GPT-5)
There was a problem hiding this comment.
Pull request overview
This PR ensures playAudio() properly rejects when ffplay fails to spawn (e.g., not installed), by handling the child process’ asynchronous error event instead of allowing an uncaught EventEmitter error.
Changes:
- Attach an
errorevent listener to the spawnedffplayprocess to reject theplayAudio()promise on spawn failure. - Add a regression test that simulates a spawn failure and asserts the promise rejects with the original error.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/helpers/audio.ts |
Adds ffplay child-process error handling so playAudio() rejects cleanly on spawn failures. |
tests/helpers/audio.test.ts |
Adds a test covering async spawn failure (error event) and verifies promise rejection behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes being requested
Handle the asynchronous
errorevent from theffplaychild process inplayAudio().When
ffplaycannot be started—for example, when it is not installed—spawn()returns a child process and reports the failure asynchronously. Without anerrorlistener, Node.js throws an uncaught EventEmitter error and the promise returned byplayAudio()does not reject normally.This change attaches the listener immediately after spawning and adds a regression test confirming that callers receive the original spawn error as a rejected promise.
Additional context & links
Validation:
pnpm test— 120 suites passed, 1,463 tests passedpnpm lint— formatting, ESLint, type checks, package checks, and JSR publish dry run passedpnpm build— Node.js and Deno builds passedSome portions of this contribution were developed with assistance from OpenAI Codex (GPT-5). The final diff and test results were reviewed locally.