From ef87b9211ed91c46e560c4f4e50ca8cd8687af13 Mon Sep 17 00:00:00 2001 From: Maz Date: Tue, 4 Jun 2024 17:10:05 +0100 Subject: [PATCH] fix: iOS Safari crash fix 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. --- app/components/App.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/components/App.tsx b/app/components/App.tsx index 89a9a4ef..aa71a272 100644 --- a/app/components/App.tsx +++ b/app/components/App.tsx @@ -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) => {