fix(participant): guard chunk restart so a dead mic ends as an interruption - #1033
Draft
posthog-eu[bot] wants to merge 1 commit into
Draft
fix(participant): guard chunk restart so a dead mic ends as an interruption#1033posthog-eu[bot] wants to merge 1 commit into
posthog-eu[bot] wants to merge 1 commit into
Conversation
…uption The chunk recorder restarts each chunk from onstop by calling startRecordingChunk again, which ends in an unguarded recorder.start(). When the mic track dies between chunks (the participant takes a call, or another app grabs the device), start() throws NotSupportedError and the throw escapes onstop: isRecording stays true, no more chunks upload, and the participant loses the rest of the recording with no alert. Wrap the restart start() in a try/catch that mirrors the startRecording failure path: release the mic, drop the recorder, clear isRecording, and raise the same interruption the participant already gets for a dead mic. The initial start (from startRecording) still propagates so its own caller handles it. Also guard the previous-recorder stop() on state === "recording", the way stopRecording and pauseRecording do. A restart runs from onstop where that recorder is already inactive, and stop() on an inactive recorder throws too. Generated-By: PostHog Desktop Task-Id: 0a01a33f-1277-42a8-8087-d93f2358e066
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.
Problem
useChunkedAudioRecorderrestarts each chunk from theonstophandler, ending in an unguardedrecorder.start(). When the mic track dies between chunks (the participant takes a call, or another app grabs the device),start()throwsNotSupportedErrorand the throw escapesonstop.isRecordingstaystrue, no furtherondataavailableoronstopfires, the suspicious-chunk detection never runs, andonRecordingInterruptedis never called. The participant gets no alert and every second of audio after that point is lost.Changes
start()in a try/catch that mirrors the existingstartRecordingfailure path: release the mic, drop the recorder, clearisRecording, and raise the same interruption the participant already gets for a dead mic (alert sound + interruption modal viaonRecordingInterrupted).onstopand the restart timer) are handled locally; the initialstart()fromstartRecordingstill propagates so its own caller resets state and returnsfalse. A newisRestartflag draws that line.stop()onstate === "recording"(asstopRecordingandpauseRecordingdo). A restart runs fromonstop, where that recorder is already inactive, andstop()on an inactive recorder throws too.playInterruptionAlerthelper shared by both interruption paths.Testing
onRecordingInterruptedfires,isRecordingdrops tofalse, and the dead mic is released.useChunkedAudioRecorder.test.tsx: 7 passed.Agent context
start()throw. Reproducing the restart path in the test uncovered a second unguarded throw in the same loop (stop()on the already-inactive previous recorder), fixed the same way.Created with PostHog Desktop from this inbox report.