fix(react-native): expo-file-system detection broken on Expo SDK 54 stable#3156
Merged
marandaneto merged 4 commits intomainfrom Feb 26, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
f9c9073 to
6b0bbb8
Compare
Contributor
Contributor
|
Size Change: -162 B (0%) Total Size: 6.66 MB
ℹ️ View Unchanged
|
…table - Prefer new File/Paths API over legacy readAsStringAsync/writeAsStringAsync - Fix incorrect Paths.document.info().uri usage, use File(Paths.document, key) per Expo docs - Legacy fallback only used for SDK <=53 where new API doesn't exist - Works correctly across SDK 53, 54 (beta+stable), and 55 Closes #3151
6b0bbb8 to
9ac489f
Compare
8 tasks
ioannisj
approved these changes
Feb 26, 2026
Contributor
ioannisj
left a comment
There was a problem hiding this comment.
Did not go into great details but changes seem reasonable.
| if (legacyModule && typeof legacyModule.readAsStringAsync === 'function') { | ||
| return buildLegacyStorage(legacyModule) | ||
| } | ||
| } catch (e) {} |
Contributor
There was a problem hiding this comment.
We are completely silent here, should we log something?
Member
Author
There was a problem hiding this comment.
mm why? its a valid path/supported path using older versions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
posthog-react-nativethrowsError: Method writeAsStringAsync imported from "expo-file-system" is deprecatedon every storage write when used with Expo SDK 54 stable.The previous fix (#2234) checked whether
readAsStringAsyncexists to decide between legacy and new File API paths. This worked for SDK 54 beta (where legacy methods were completely removed), but breaks on SDK 54 stable where legacy methods are still exported as functions — they just throw a deprecation error when called.Additionally, the new File API usage was incorrect —
Paths.document.info().uriis not valid per the Expo docs.Paths.documentis aDirectoryinstance and theFileconstructor accepts(Directory, ...strings)for path joining.Closes #3151
Changes
Reordered detection logic in
buildOptimisiticAsyncStorage():Paths/Fileon the mainexpo-file-systemmodule — if present (SDK 54+), use the new File APIreadAsStringAsyncvia the legacy subpath (expo-file-system/legacy, SDK 55+) or the main module (SDK ≤53)This is safe because the deprecated throwing stubs and the new
Paths/FileAPI were introduced in the same version (expo-file-system v19). By checking forPaths/Filefirst and returning early, we ensure the legacy fallback only runs on SDK ≤53 wherereadAsStringAsyncis a real working function.Fixed File API usage: Changed from
new File(Paths.document.info().uri + key)tonew File(Paths.document, key)per the Expo filesystem docs.Detection matrix across all Expo versions:
Paths/FilereadAsStringAsyncbuildLegacyStorage()/legacysubpath)Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file