PostHog / posthog-js-lite

Reimplementation of posthog-js to be as light and modular as possible.
https://posthog.com/docs/libraries
MIT License
65 stars 32 forks source link

Error: Calling the 'writeAsStringAsync' function has failed → Caused by: File '/var/mobile/Containers/Data/Application/XXXXXXXXXXXXXX/Documents/.posthog-rn.json' is not writable #288

Open noahkurz opened 4 days ago

noahkurz commented 4 days ago

The error "Error: Calling the 'writeAsStringAsync' function has failed → Caused by: File '/var/mobile/Containers/Data/Application/XXXXXXXXXXXXXDocuments/.posthog-rn.json' is not writable" showed up in my sentry logs three times.

It's hard to pinpoint commonalities with the three events I have gotten, but it seems related to pressing a text component inside of an animated view?

V3.1.2 of posthog-react-native

OS: iOS only as of right now.

Let me know if any other information is needed! I've seen this 3 times in production so far.

marandaneto commented 4 days ago

@noahkurz thanks for the issue, I transferred the issue to the right repo. writeAsStringAsync comes from https://github.com/PostHog/posthog-js-lite/blob/dfd70e6cb0dfdaf1b8cccc19f5531b846b8f4f6c/posthog-react-native/src/native-deps.tsx#L81 and here https://github.com/PostHog/posthog-js-lite/blob/dfd70e6cb0dfdaf1b8cccc19f5531b846b8f4f6c/posthog-react-native/src/storage.ts#L4 Which storage do you use? expo-file-system or @react-native-async-storage/async-storage? Which version? I think this is an edge case where the app doesn't have write permissions in the folder, not sure we can do something about it.

noahkurz commented 4 days ago

Wow, thanks for the quick response and tracking down of this issue. I currently have both because I am migrating away from async storage, so looking at the code it should be boiling down to expo-file-system here. I am on version 17.0.1.

marandaneto commented 2 days ago

It's hard to pinpoint commonalities with the three events I have gotten, but it seems related to pressing a text component inside of an animated view?

It's hard to pinpoint commonalities with the three events I have gotten, but it seems related to pressing a text component inside of an animated view?

If it breaks when saving a file, the action can be anything, if the file isn't writable it seems to be something like the device, the simulator/environment the app is running, can you reproduce this issue? Is that happening only in production with real users? Do you have any more details?

noahkurz commented 2 days ago

I cannot recreate the issue myself and it is only happening with real users in production. It is very rare as it is currently 0.002 percent of my users.

The users are on iOS 17.4.1 or 17.6.1

All of the events happened in the same build and version of my app. (which is very weird)

The device type is either iPhone 12 pro or iPhone 13 pro max.

Sadly that is the only meaningful information I have at this time. 😢