fix(electron): report a failed ffmpeg download as ELECTRON_INSTALL_FAILED and read a package.json with a byte order mark
KD
22m ago+65+65+01234567890123456789-10-10-01234567890123456789
What
- A failed ffmpeg download for video fails the recording with
ELECTRON_INSTALL_FAILED, an infrastructure error, as a failed Electron download does. It used to surface asENGINE_FAILURE. - A machine with no VP9 ffmpeg on its
PATHis checked for one once per process, not before every recording. - An app whose
package.jsonstarts with a byte order mark (which some Windows editors write) passes theapp.appPathcheck. Electron reads past the mark, but the check said the file was not valid JSON.
Why
Three small Electron engine bugs found while working on the Electron download. A machine that cannot reach GitHub saw ENGINE_FAILURE for a network failure, which reads as an engine bug and is not counted as infrastructure. A CI machine with no ffmpeg ran ffmpeg -encoders before each recording. A Windows project with a BOM in package.json failed before the first test with a wrong message.
The lock around the Electron download that this PR started with is left to #2470, which holds the lock in the process that runs install.js and also handles a stale path.txt. This branch merges with #2470 without conflicts.
How it works
translatereturns anInfrastructureErrorunchanged (packages/electron/src/errors.ts:43), as it already did forConfigurationErrorandTestError. Before, it fell through to the generic wrap, since anInfrastructureErroris not anEngineError. The only one raised inside an operation's budget isensureFfmpeginvideo start, which sends no input.ensureFfmpegkeeps a miss on thePATH(null) as well as a hit (packages/electron/src/ffmpeg.ts:60);??=re-ran the probe after everynull.appPathProblemstrips a leadingbefore it parsespackage.json(packages/electron/src/executable.ts:256).- Docs:
reference/errors.mdxlists the ffmpeg download underELECTRON_INSTALL_FAILED. The reference's Video row says a failed download fails the recording and gives the order the engine finds ffmpeg in, with the cached download before thePATH. The guide no longer repeats that order.
Verified
Ran it locally: yes, on macOS (Apple Silicon).
- The Electron package's unit tests pass (115), with typecheck and oxlint.
git merge-treeagainst #2470's head (fa55008c0) reports no conflicts. - main against this branch: this branch's tests run against
origin/main'spackages/electron/src. These fail there and pass here:
| Suite | Test | main | this PR |
|---|---|---|---|
| unit | translate leaves a refusal by policy or of the test's own input as it is | fails | passes |
| unit | ensureFfmpeg checks the PATH for ffmpeg once, and fails a download that failed with ELECTRON_INSTALL_FAILED | fails | passes |
| unit | app.appPath takes a main script, or a directory whose main script exists, and says what is wrong otherwise | fails | passes |
- Benchmark: not run, the remaining changes touch only install and ffmpeg error paths the testbed suite never takes.
- Video: none. Nothing changes on screen.
🤖 Generated with Claude Code
Summary by CodeRabbit
- Documentation
- Clarified how video recording locates or downloads ffmpeg, including configuration options and the errors shown when it is unavailable.
- Bug Fixes
- Failed ffmpeg downloads now report the appropriate installation error.
- Fixed app detection when a package file begins with a byte-order mark.
- Avoided repeating the ffmpeg availability check after it has already found ffmpeg unavailable.