Skip to content

TypeError: Cannot read property '__internal_toSnapshot' of undefined when using __experimental_resourceCache in ClerkProvider (Expo App Offline Support) #6010

@dzmitryFesik

Description

@dzmitryFesik

Preliminary Checks

Reproduction

https://github.com/clerk/clerk-expo-quickstart

Publishable key

pk_test_ZmFpdGhmdWwtbW9ua2Zpc2gtNS5jbGVyay5hY2NvdW50cy5kZXYk

Description

Steps to reproduce:

  1. Follow the official Clerk Expo offline support guide.
  2. Set up with tokenCache and __experimental_resourceCache props:
    Note: Neither @clerk/clerk-expo/resource-cache (after before 2.9.0) nor @clerk/clerk-expo/secure-store (before 2.9.0) works:
 <ClerkProvider tokenCache={tokenCache} __experimental_resourceCache={resourceCache}>
   {/* children */}
 </ClerkProvider>
  1. Attempt to sign in using:
const signInResponse = await signIn.create({
  strategy: 'password',
  identifier: formData.email,
  password: formData.password,
})

Expected behavior:

App should support offline mode without throwing runtime errors when using __experimental_resourceCache.

Actual behavior:

App throws an error:

[TypeError: Cannot read property '__internal_toSnapshot' of undefined]

This happens as soon as signIn.create(...) is called, only when __experimental_resourceCache is present. When that prop is removed, everything works correctly.

Reproduction in clerk-expo-quickstart

clerk-expo-offline_rT83G6vh.mp4

Offline support is super important for our app since many users work in poor connectivity areas. Not sure if this is something wrong in my setup, the SDK, or how I'm using it. Any help or workaround would be awesome!

Thanks a lot for all the great work on this SDK!

Environment

System:
  OS: macOS 15.4.1
  CPU: (8) arm64 Apple M1 Pro
  Memory: 128.27 MB / 32.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
  Yarn: 1.22.22 - ~/.nvm/versions/node/v22.14.0/bin/yarn
  npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
  pnpm: 10.9.0 - ~/.nvm/versions/node/v22.14.0/bin/pnpm
  Watchman: 2024.10.28.00 - /opt/homebrew/bin/watchman
Browsers:
  Chrome: 136.0.7103.114
  Safari: 18.4
npmPackages:
  @babel/core: ^7.26.10 => 7.26.10
  @clerk/clerk-expo: ^2.8.5 => 2.8.5
  @expo/vector-icons: ^14.0.4 => 14.0.4
  @react-native-community/cli-server-api: ^15.1.0 => 15.1.3
  @react-navigation/native: ^7.0.0 => 7.0.15
  @types/jest: ^29.5.14 => 29.5.14
  @types/react: ~18.3.12 => 18.3.18
  @types/react-test-renderer: 18.0.7 => 18.0.7
  expo: ^52.0.39 => 52.0.39
  expo-constants: ~17.0.8 => 17.0.8
  expo-font: ~13.0.4 => 13.0.4
  expo-linking: ~7.0.5 => 7.0.5
  expo-router: ~4.0.18 => 4.0.18
  expo-secure-store: ~14.0.1 => 14.0.1
  expo-splash-screen: ~0.29.22 => 0.29.22
  expo-status-bar: ~2.0.1 => 2.0.1
  expo-system-ui: ~4.0.8 => 4.0.8
  expo-web-browser: ~14.0.2 => 14.0.2
  jest: ^29.7.0 => 29.7.0
  jest-expo: ~52.0.6 => 52.0.6
  react: 18.3.1 => 18.3.1
  react-dom: 18.3.1 => 18.3.1
  react-native: 0.76.3 => 0.76.3
  react-native-gesture-handler: ~2.24.0 => 2.24.0
  react-native-reanimated: ~3.17.1 => 3.17.1
  react-native-safe-area-context: 4.12.0 => 4.12.0
  react-native-screens: ~4.9.2 => 4.9.2
  react-native-web: ~0.19.13 => 0.19.13
  react-test-renderer: 18.2.0 => 18.2.0
  typescript: ~5.8.2 => 5.8.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingexpo

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions