Skip to content

fix: replace force-unwraps with guards in TextDecoder.decodeText#424

Open
yw5aj wants to merge 1 commit intoargmaxinc:mainfrom
yw5aj:fix/safe-unwrap-text-decoder
Open

fix: replace force-unwraps with guards in TextDecoder.decodeText#424
yw5aj wants to merge 1 commit intoargmaxinc:mainfrom
yw5aj:fix/safe-unwrap-text-decoder

Conversation

@yw5aj
Copy link

@yw5aj yw5aj commented Feb 19, 2026

Fixes #414

Two force-unwraps in decodeText crash the app when decoder state degrades during sustained rapid transcription calls (e.g., live transcription preview at ~5 calls/sec):

  • Line 747: decoderInputs.initialPrompt.last! — crashes when initialPrompt is empty
  • Line 829: decoderOutput.logits! — crashes when logits is nil

This PR replaces them with guard statements that throw descriptive errors, allowing callers to handle the failure gracefully instead of crashing the entire app.

Minimal diff — no behavioral change for normal operation

The guard statements only trigger when the values are unexpectedly nil. Normal transcription flow is unaffected.

Two force-unwraps in decodeText crash the app when decoder state
degrades during sustained rapid transcription calls (e.g. live preview):

- initialPrompt.last\! crashes when initialPrompt is empty
- decoderOutput.logits\! crashes when logits is nil

Replace with guard statements that throw descriptive errors, allowing
callers to handle the failure gracefully instead of crashing.

Fixes argmaxinc#414
@ZachNagengast
Copy link
Contributor

Interesting, third PR this week for this specific issue #420 #417. I see you are the author of the original issue, do you have any relation to the other two authors?

@yw5aj
Copy link
Author

yw5aj commented Feb 19, 2026

No relation — we're an independent team that hit the same crash during live transcription. Glad to see others confirming the issue. Happy to defer to whichever PR you prefer to merge!

@ZachNagengast
Copy link
Contributor

ZachNagengast commented Feb 19, 2026

👍󠄳󠅜󠅟󠅣󠅕

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.

TextDecoder.decodeText force-unwraps cause crashes during repeated live transcription

2 participants