fix: /record duration shows Infinity/NaN until first seek (#1255)
root cause is a well-known MediaRecorder quirk: blobs it produces have
no duration written into the webm/ogg container header, so
<audio>.duration reads as Infinity until the browser scans the full
file. the fix is the MDN-documented workaround — on loadedmetadata,
if duration is non-finite, seek to a huge time value (1e101), wait for
the durationchange event where duration becomes real, then reset
currentTime to 0.
changes in frontend/src/routes/record/+page.svelte:
- new handleLoadedMetadata wired to <audio onloadedmetadata={...}>
that triggers the seek-to-EOF workaround when duration is not finite
- playbackProgress guards against non-finite duration (was silently
returning 0 which made the waveform playhead never advance)
- handleSeek guards against non-finite duration so clicks on the
waveform during the brief pre-durationchange window are no-ops
- formatTime treats Infinity / NaN / negative as 0 so the display
never shows "NaN:NaN" or "Infinity:00" in any transient state
- reRecord resets currentTime, duration, and isPlaying so a second
take doesn't inherit playback state from the first
separately fixed at the same time (not in this PR): the prod backend
was missing TRANSCODER_AUTH_TOKEN which caused the transcoder to
reject webm uploads with 401. secret copied from staging and both
relay-api machines rolled successfully — a latent pre-existing bug
unrelated to the frontend fix here.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
authored by