Skip to content

Commit

Permalink
fix: iOS Safari crash fix
Browse files Browse the repository at this point in the history
When using Safari on iOS, an empty packet is sent within the first few seconds of connecting. This causes the connection to close. By checking that e.data.size > 0, we only send packets with data to the Deepgram API, preventing this from happening.
  • Loading branch information
mazshakibaii authored Jun 4, 2024
1 parent fbf0bc4 commit ef87b92
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ const App: () => JSX.Element = () => {
if (!connection) return;

const onData = (e: BlobEvent) => {
connection?.send(e.data);
// iOS SAFARI FIX:
// Prevent packetZero from being sent. If sent at size 0, the connection will close.
if (e.data.size > 0) {
connection?.send(e.data);
}
};

const onTranscript = (data: LiveTranscriptionEvent) => {
Expand Down

0 comments on commit ef87b92

Please sign in to comment.