Skip to content

fix: production hardening — critical issues for 24/7 deployment - #18

Merged
johnoct merged 1 commit into
mainfrom
fix/production-hardening-v2
Feb 7, 2026
Merged

fix: production hardening — critical issues for 24/7 deployment#18
johnoct merged 1 commit into
mainfrom
fix/production-hardening-v2

Conversation

@johnoct

@johnoct johnoct commented Feb 7, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes 5 critical and 3 high-severity issues identified during production readiness review:

Critical fixes:

  • MJPEG stream generator now handles GeneratorExit to prevent leaked threads on client disconnect
  • Web server uses waitress (production WSGI) instead of Flask dev server, with fallback
  • Audio monitor health check in main loop — detects dead thread, notifies user, disables audio
  • Audio callback race condition fixed — all calibration state mutations now under lock
  • CPU spin on camera frame failures — added time.sleep(0.1) before continue

High fixes:

  • snap_path initialized to None to prevent potential UnboundLocalError
  • cv2.waitKey only called when preview window is active (fixes headless mode)
  • /settings endpoint handles non-integer FPS input gracefully (no more 500 errors)

Other:

  • Audio callback now logs stream status warnings (overflow, underflow)
  • Bumped pyproject.toml version to 2.0.0
  • Added waitress to dependencies (requirements.txt, pyproject.toml, CI workflows)
  • 15 new tests covering all fixes (189 total passing)

Test plan

  • All 189 tests pass locally
  • CI passes on PR
  • Verify waitress serves web UI correctly
  • Verify MJPEG stream cleanup on tab close
  • Verify audio health notification on device disconnect

- MJPEG stream handles GeneratorExit on client disconnect
- Use waitress production server (fallback to Flask dev)
- Audio health check in main loop: detect dead thread, notify, disable
- Audio callback race condition: all calibration state under lock
- CPU spin on frame failures: add sleep before continue
- Initialize snap_path to prevent potential UnboundLocalError
- Only call cv2.waitKey when preview window is active
- Handle non-integer FPS in /settings gracefully
- Log audio stream status warnings (overflow/underflow)
- Bump pyproject.toml version to 2.0.0
- Add 15 new tests covering all fixes (189 total passing)
@johnoct
johnoct merged commit 0f3b1d8 into main Feb 7, 2026
1 check passed
@johnoct
johnoct deleted the fix/production-hardening-v2 branch February 7, 2026 02:39
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.

1 participant