-
Notifications
You must be signed in to change notification settings - Fork 499
Description
Describe the bug
When attempting Apple sign‑in in an Expo app using @supabase/supabase-js@2.51.0, the client throws a runtime ReferenceError: Property 'structuredClone' doesn't exist. This error occurs regardless of JS engine (Hermes or JSC) and blocks native authentication flows that rely on structuredClone.
To Reproduce
-
In a fresh Expo SDK 53 project, install Supabase JS at v2.51.0:
npm install @supabase/supabase-js@2.51.0
-
Configure
jsEngineto either Hermes or JSC inapp.json. -
Use this minimal repro code:
import * as AppleAuthentication from 'expo-apple-authentication'; import { supabase } from './supabaseClient'; export async function signInWithApple() { try { const credential = await AppleAuthentication.signInAsync({ requestedScopes: [ AppleAuthentication.AppleAuthenticationScope.FULL_NAME, AppleAuthentication.AppleAuthenticationScope.EMAIL, ], }); if (!credential.identityToken) { throw new Error('No identityToken returned from Apple.'); } const { error, data: { user } } = await supabase.auth.signInWithIdToken({ provider: 'apple', token: credential.identityToken, }); if (error) { console.error('Supabase auth error:', error); } else { console.log('✓ Signed in:', user); } } catch (e: any) { if (e.code === 'ERR_REQUEST_CANCELED') { console.log('User cancelled Apple sign‑in'); } else { console.error(e); } } }
-
Run the app and attempt Apple sign‑in.
-
Observe the Metro console error:
ReferenceError: Property 'structuredClone' doesn't existThe app crashes before completing the flow.
Expected behavior
Native sign‑in flows should work without requiring a global structuredClone. The client should either polyfill it on unsupported engines or avoid relying on it entirely. Behavior should match v2.50.5, where Apple sign‑in works under Expo.
Screenshots
n/a — error is shown in Metro/console and app terminates.
System information
- Expo SDK: 53 (React Native 0.79.5)
- JS Engine: Hermes (also reproduces on JSC)
- Version of
@supabase/supabase-js: 2.51.0 - Version of Node.js: 18.16.0
- Library for Apple auth:
expo-apple-authentication@7.2.4
Additional context
- Downgrading to
@supabase/supabase-js@2.50.5resolves the issue: Apple sign‑in completes successfully under Expo when using v2.50.5. - A fix has been proposed in Expo’s PR [#37503](feat(expo): add structuredClone to native apps expo/expo#37503), which would add a
structuredClonepolyfill for native apps. That PR is still open, all CI checks are passing, but it’s awaiting at least one approving review and resolution of a few reviewer concerns (stringification logic and transfer semantics) before merge. - Once merged—or if Supabase JS bundles its own fallback—the Apple sign‑in error should be resolved. Let me know if you need further logs, test results under Hermes, or any adjustments to the proposed implementation.