Skip to content

fix: prevent memory leaks and silent export failures#552

Open
arnow117 wants to merge 5 commits into
THU-MAIC:mainfrom
arnow117:fix/frontend-hooks-memory-leaks
Open

fix: prevent memory leaks and silent export failures#552
arnow117 wants to merge 5 commits into
THU-MAIC:mainfrom
arnow117:fix/frontend-hooks-memory-leaks

Conversation

@arnow117
Copy link
Copy Markdown

Summary

  • use-browser-asr: Added cleanup on unmount to abort active SpeechRecognition and release the microphone. Without this, navigating away while recording leaves the mic locked.
  • use-streaming-text: Stabilized onComplete callback with useRef to prevent animation restarts when parent re-renders. Previously, any re-render that created a new onComplete function reference would restart the entire streaming animation.
  • use-export-pptx: Added resp.ok checks at 3 fetch() calls to avoid silently embedding corrupted images/media when HTTP requests fail (e.g., 403, 404, 500). Failed resources are now skipped with a warning log.

Test plan

  • Verify mic is released after unmounting a component that uses useBrowserASR while recording
  • Verify streaming text animation does not restart when a sibling component re-renders
  • Export a presentation containing external images that return 404 — confirm no crash and a warning is logged instead of a corrupted PPTX

arnow117 added 5 commits May 10, 2026 09:50
- use-browser-asr: add cleanup on unmount to abort active
  SpeechRecognition and release microphone
- use-streaming-text: use ref for onComplete callback to prevent
  animation restarts when parent re-renders
- use-export-pptx: check resp.ok before consuming fetch bodies to
  avoid silent failures with corrupted images in exported slides
The else block was missing its closing brace, causing Turbopack
parse errors in CI (4 "Expected a semicolon" errors).
Log statements exceeded printWidth limit — Prettier auto-wrapped.
…SLint rule

ESLint error: "Cannot access refs during render" — moved
`onCompleteRef.current = onComplete` into its own useEffect.
Also removed now-unnecessary eslint-disable comment.
Removing the directive exposed a pre-existing lint error on line 72.
The actual fix (ref assignment in useEffect) is preserved.
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