Skip to content

fix: cap audio device enumeration and give a clear error on hang (#40)#44

Merged
TMHSDigital merged 1 commit into
mainfrom
fix/40-audio-enum-timeout
Jun 16, 2026
Merged

fix: cap audio device enumeration and give a clear error on hang (#40)#44
TMHSDigital merged 1 commit into
mainfrom
fix/40-audio-enum-timeout

Conversation

@TMHSDigital

Copy link
Copy Markdown
Owner

Summary

Fixes #40. list_audio_devices (and start_recording with audio.source: "system", which resolves the loopback device first) could hang for the full 30s timeout and then fail with the raw ffmpeg timed out after 30s, instead of listing devices or giving an actionable message. The dshow -list_devices probe blocks on some setups (a misbehaving audio driver, or no audio hardware).

Changes

  • Enumeration timeout dropped from 30s to a 12s ENUM_TIMEOUT_MS cap.
  • The child's stdin is closed during enumeration (runCapture gained a closeStdin option) - a known cause of the dshow probe hanging.
  • A timeout or spawn failure now becomes a clear Could not enumerate audio devices (...) error with a fix hint, instead of the raw ffmpeg timed out text.
  • A successful enumeration is cached for the process lifetime, so an audio recording no longer re-pays the probe (or risks the hang) on every start. list_audio_devices forces a fresh probe (forceRefresh), so a device enabled mid-session still shows up. clearAudioDeviceCache() drops the cache.

Notes

The pure parse/pick helpers are unchanged and still covered. The new timeout/cache behavior is integration-level (it spawns ffmpeg); the suite deliberately keeps unit tests pure and mocks nothing, so no spawn-mocked test was added.

Verification

npm run build, npm run typecheck, npm test all pass (136 passed, 6 skipped).

🤖 Generated with Claude Code

The dshow -list_devices probe can block on some setups (a misbehaving audio
driver), so list_audio_devices and system-audio recording could hang the full
30s and return the raw "ffmpeg timed out" text. Enumeration now uses a 12s cap,
closes the child's stdin (a known hang cause), and surfaces a clear, actionable
error. A successful result is cached for the process so a recording does not
re-pay the probe; list_audio_devices forces a fresh probe.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@TMHSDigital TMHSDigital force-pushed the fix/40-audio-enum-timeout branch from 92c1c66 to 119c101 Compare June 16, 2026 23:17
@TMHSDigital TMHSDigital merged commit dc65354 into main Jun 16, 2026
1 check passed
@TMHSDigital TMHSDigital deleted the fix/40-audio-enum-timeout branch June 16, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: list_audio_devices and system-audio capture can hang ~30s and return a misleading timeout

1 participant