react-native: Xcode 14.3 - Error: Unable to resolve module ./Libraries/Components/DatePicker/DatePickerIOS
This issue is now fixed, for more details check out this comment.
Description
Since upgrading to Xcode 14.3 and working around the other new issues i.e. the codegen ios target version issue, there is still a further issue with metro. Getting a lot of these type of errors. It seems to be every time metro logs a log line from iOS (not Android), it then logs the below message as well (full paths redacted).
This seems to cause a memory leak as well, with the metro node process eventually crashing when > 4GB RAM is used.
The error message is interesting for many reasons.
- Firstly it seems to be trying to resolve a flow type import.
- Secondly the path does exist, but metro is not checking the platform-specific path i.e.
DatePickerIOS.ios.js
. - Thirdly we don’t even use
DatePickerIOS
in the app.
None of these files exist:
* node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS(.native|.native.js|.js|.native.json|.json|.native.ts|.ts|.native.tsx|.tsx|.native.engine.js|.engine.js)
* node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS/index(.native|.native.js|.js|.native.json|.json|.native.ts|.ts|.native.tsx|.tsx|.native.engine.js|.engine.js)
15 | import typeof ActivityIndicator from './Libraries/Components/ActivityIndicator/ActivityIndicator';
16 | import typeof Button from './Libraries/Components/Button';
> 17 | import typeof DatePickerIOS from './Libraries/Components/DatePicker/DatePickerIOS';
| ^
18 | import typeof DrawerLayoutAndroid from './Libraries/Components/DrawerAndroid/DrawerLayoutAndroid';
19 | import typeof FlatList from './Libraries/Lists/FlatList';
20 | import typeof Image from './Libraries/Image/Image';
at ModuleResolver.resolveDependency (node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:107:15)
at DependencyGraph.resolveDependency (node_modules/metro/src/node-haste/DependencyGraph.js:288:43)
at Object.resolve (node_modules/metro/src/lib/transformHelpers.js:129:24)
at resolve (node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
at node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
at Array.reduce (<anonymous>)
at resolveDependencies (node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
at processModule (node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31)
at async addDependency (node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18)
at async Promise.all (index 9)
NOTE that this is not the codegen ios target version issue, I’ve already worked around that using the patch which has been released as 0.70.8
React Native Version
0.70.6
Output of npx react-native info
System:
OS: macOS 13.3
CPU: (8) arm64 Apple M1 Pro
Memory: 1.78 GB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 16.10.0 - ~/.nvm/versions/node/v16.10.0/bin/node
Yarn: 1.22.19 - ~/redacted/node_modules/.bin/yarn
npm: 8.0.0 - ~/redacted/node_modules/.bin/npm
Watchman: 2023.02.27.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /redacted/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
Android SDK: Not Found
IDEs:
Android Studio: 2021.3 AI-213.7172.25.2113.9014738
Xcode: 14.3/14E222b - /usr/bin/xcodebuild
Languages:
Java: 17.0.4.1 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.67.1 => 0.67.1
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps to reproduce
Running a previously working app on Xcode 14.3 / iOS simulator with rosetta
Snack, code example, screenshot, or link to a repository
Can’t provide one at this stage
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 113
- Comments: 112 (15 by maintainers)
Commits related to this issue
- Support ';&' as an alternative to '?' in bundle URLs Summary: Recent versions of JavaScriptCore strip query strings from `Error.prototype.stack`, which breaks our use of query strings to carry bundle... — committed to robhogan/metro by robhogan a year ago
- Support ';&' as an alternative to '?' in bundle URLs (#974) Summary: Pull Request resolved: https://github.com/facebook/metro/pull/974 Recent versions of JavaScriptCore strip query strings from `Err... — committed to robhogan/metro by robhogan a year ago
- Support ';&' as an alternative to '?' in bundle URLs (#974) Summary: Pull Request resolved: https://github.com/facebook/metro/pull/974 Recent versions of JavaScriptCore strip query strings from `Err... — committed to robhogan/metro by robhogan a year ago
- Use `Content-Location` header in bundle response as JS source URL Summary: This is the iOS side of the fix for https://github.com/facebook/react-native/issues/36794. That issue aside for the moment,... — committed to robhogan/react-native by robhogan a year ago
- Emit JSC-safe URLs in HMR, `//# sourceURL`, `Content-Location` Summary: The remaining Metro part of the implementation of https://github.com/react-native-community/discussions-and-proposals/pull/646,... — committed to robhogan/metro by robhogan a year ago
- Use `Content-Location` header in bundle response as JS source URL (#37501) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37501 This is the iOS side of the fix for htt... — committed to robhogan/react-native by robhogan a year ago
- Use `Content-Location` header in bundle response as JS source URL (#37501) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37501 This is the iOS side of the fix for htt... — committed to robhogan/react-native by robhogan a year ago
- Use `Content-Location` header in bundle response as JS source URL (#37501) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37501 This is the iOS side of the fix for htt... — committed to robhogan/react-native by robhogan a year ago
- Use `Content-Location` header in bundle response as JS source URL (#37501) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37501 This is the iOS side of the fix for htt... — committed to facebook/react-native by robhogan a year ago
- Emit JSC-safe URLs in HMR, `//# sourceURL`, `Content-Location` (#989) Summary: Pull Request resolved: https://github.com/facebook/metro/pull/989 The remaining Metro part of the implementation of htt... — committed to robhogan/metro by robhogan a year ago
- Accept bundle and symbolication requests in JSC-safe format (`//&` in place of `?`) Summary: The first part of implementing https://github.com/react-native-community/discussions-and-proposals/pull/64... — committed to facebook/metro by robhogan a year ago
- Emit JSC-safe URLs in HMR, `//# sourceURL`, `Content-Location` (#989) Summary: Pull Request resolved: https://github.com/facebook/metro/pull/989 The remaining Metro part of the implementation of htt... — committed to facebook/metro by robhogan a year ago
- Use `Content-Location` header in bundle response as JS source URL (#37501) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37501 This is the iOS side of the fix for htt... — committed to facebook/react-native by robhogan a year ago
- Accept bundle and symbolication requests in JSC-safe format (`//&` in place of `?`) Summary: The first part of implementing https://github.com/react-native-community/discussions-and-proposals/pull/64... — committed to facebook/metro by robhogan a year ago
- Emit JSC-safe URLs in HMR, `//# sourceURL`, `Content-Location` (#989) Summary: Pull Request resolved: https://github.com/facebook/metro/pull/989 The remaining Metro part of the implementation of htt... — committed to facebook/metro by robhogan a year ago
- Emit JSC-safe URLs in HMR, `//# sourceURL`, `Content-Location` (#989) Summary: Pull Request resolved: https://github.com/facebook/metro/pull/989 The remaining Metro part of the implementation of htt... — committed to facebook/metro by robhogan a year ago
- Accept bundle and symbolication requests in JSC-safe format (`//&` in place of `?`) Summary: The first part of implementing https://github.com/react-native-community/discussions-and-proposals/pull/64... — committed to facebook/metro by robhogan a year ago
- Emit JSC-safe URLs in HMR, `//# sourceURL`, `Content-Location` (#989) Summary: Pull Request resolved: https://github.com/facebook/metro/pull/989 The remaining Metro part of the implementation of htt... — committed to facebook/metro by robhogan a year ago
- Accept bundle and symbolication requests in JSC-safe format (`//&` in place of `?`) Summary: The first part of implementing https://github.com/react-native-community/discussions-and-proposals/pull/64... — committed to facebook/metro by robhogan a year ago
- Emit JSC-safe URLs in HMR, `//# sourceURL`, `Content-Location` (#989) Summary: Pull Request resolved: https://github.com/facebook/metro/pull/989 The remaining Metro part of the implementation of htt... — committed to facebook/metro by robhogan a year ago
Update
Impact
Runtime errors encountered during development cannot be symbolicated (=stack traces made readable)
Affected users and versions
Root cause
A recent change to JavaScriptCore strips query strings from source URLs in stack traces. Thanks again @AndreasLS for the pointer. CC @rreno, @JonWBedard from WebKit for awareness - would love to chat about this!
Symptoms
When any (unrelated) error or warning (redbox/yellowbox) originates in anywhere your app’s JS code during development, the client sends a
/symbolicate
request to Metro with the stack trace. Normally, frames of that stack trace include the bundle URL with all relevant build parameters, alongside line and column numbers. Metro’s job is to map that back to your source code to show you where the error originated in a readable format. However, with query strings stripped from the stack trace, Metro fails to reconstruct your bundle because?platform=ios
is missing, and therefore it can’t resolve platform-specific code. By chance,DatePickerIOS
is usually the first platform-specific component it encounters, so you see the error in the issue title.Workarounds
server.rewriteRequestUrl
to “guess” the query string if it seems to be missing. Note that there are other parameters besidesplatform
that affect the bundle output, you’ll need to make sure these are right for your setup - details below have the defaults for areact-native init
project.Using
server.rewriteRequestUrl
inmetro.config.js
Next steps
We’re still working on what the solution should be - it will likely involve a native-side change which we’ll backport to maintained RN versions as new patch releases - and will update again here next week.
Same issue
same issue
Huge thanks @AndreasLS for nailing the root cause.
Just a quick ack - we don’t know exactly what the solution is going to be here (native workaround, major Metro change) but we’re treating it as a priority.
To reiterate, this affects JSC users and prevents Metro from correctly symbolicating error stacks. In other words it’s an error-reporting-error, and there are varying underlying errors that may cause it to appear.
hey folks - quick update; we’ve raised this to the Meta team and the Metro folks are now looking at it, expect an update from them here at some point in the near future.
A few quick observations:
Adding more context:
That was the change: https://github.com/WebKit/WebKit/blob/e214b2a322c49e1ff3aa7991b6f9478d8cbd80e5/Source/JavaScriptCore/runtime/StackFrame.cpp#L137
That was the reason: https://github.com/WebKit/WebKit/commit/71985aa1520560154a329e5b54159fff3173cf22
For the build problem you can upgrade to either 0.70.8 or 0.71.6 which contains a fix for that.
For the very odd Metro compilation error with DatePickerIOS I found the problem is using iOS simulators with iOS 16.4. If you use a iOS 15 or 16.0 simulator it doesn’t happen. You can download older simulator versions in Xcode > Window > Device and Simulators > Simulators tab
Still trying to figure out why iOS 16.4 is an issue here though. So hold tight for that.
Xcode -> Pods -> Build Settings -> Ios Deployment Target change to 12.4 and will work! 🔥
Same here, I’m on React Native
0.70.5
and XCode14.3
.This error appears whenever there is any other type of error on the app, and eventually crashes with a memory leak.
update: we just released 0.71.11 that contains the same fix we’ve put in 72 RC5, please check it out. Patches for 0.70 and 0.69 will come out in the next few weeks.
I’m in the process of preparing backports to RN 0.71 (Metro 0.73), RN 0.70 (Metro 0.72) and RN 0.69 (Metro 0.70), which I think covers the supported release range? Again, we’ll need bumps of Metro + CLI + RN, but other than the churn I don’t see any problem with picking this back.
@bennettfrazier the first release to get it will be RC4 of 72, we’re about to start testing today (found some last minute hiccups detected via CI) and given how Monday is bank holiday mostly everywhere, we’re aiming at Tues/Wed next week.
Once RC4 is out and people report that the problem is indeed addressed, we’ll evaluate if it’s viable to backport to the rest of the release window (71,70,69).
reopening until a release with the fix is out. It’s likely that we might explore also backporting this, if viable.
@Imtayaz
From what I could find, the source of the issue is that the DatePickerIOS files have the extension
.android.js
and.ios.js
. by default, the metro resolver is looking for files with the extension of.native|.native.ts|.ts|.native.tsx|.tsx|.native.js|.js|.native.jsx|.jsx|.native.json|.json
(per the error message)So all we need to do is tell metro to look for some extra stuff via the
metro.config.js
. This is mymetro.config.js
file after modifying it and eliminating my errors:I hope it helps!
More information on this can be found in the expo documentation
We’re working on rolling out supporting query-string free URLs for Metro, and altering the bundling request URL on iOS at least for JSC. It’s not a trivial fix, unfortunately, and will need point releases of Metro and RNCLI and a patch in RN backported as far as we need - it’ll likely be ~2 weeks to see this in an RN release.
This issue does not affect production builds. It purely affects error stack traces, so it’s triggered by other errors - you might try one of the workarounds above (easiest: use an older iOS version in your device/simulator) to try to find the underlying error. App store rejections could be for various other reasons, of course.
is there another way?
I’m having the same issue, I’m on version
0.69.9
and XCode14.3
~Closing this issue as~ both RN (PR https://github.com/facebook/react-native/pull/37501) and Metro (PR https://github.com/facebook/metro/pull/989) fixes have been Merged. 🎉
P.S.: Picked into
0.72-stable
Thanks, @mjmasn 🙏 for reporting this.
If this issue still persists or if there are any other concerns, then please let us know.
I had the same issue with RN 0.67.2 + iOS 16.4 combination. Enabling Hermes solved the issue.
Safari 16.4 (aka WebKit) have changed the way it logs the errors. We don’t have the complete url anymore, and the platform is on the query params. That way, the symbolication gets broken and will cause an infinity loop of reloading bundle.
Workarounds:
To emphasize, this happens on any iOS 16.4 device, simulator or physical device.
If this helps any, I’ve also run into the same Metro compilation error on my physical device on 16.4.
Same issue, React native
0.70.5
and XCode14.3
.Got the same issue, also version
0.71.6
Xcode14.3
The same issue is happening for me on version
0.71.6
of react-native and version14.3
of Xcode.@Neelshah768 @Santosl2 have you tested 0.72 RC5? As mentioned above, that’s the only version currently that has the fix, backports are in the work.
@kelset is there a target date for the release of this fix?
Thanks @robhogan 🎉
@ChristopherAChase thanks for looking to help, but I would not recommend this. Metro already prepends the target platform to the extensions it tries (with platform-specific files taking priority), the issue here is that the
platform
query string is missing, stripped by the JS engine before it reaches Metro, so Metro doesn’t know which platform to try.The problem with adding platform-style extensions to
sourceExts
is that Metro will try them regardless of the target platform - so may resolve to an.ios.js
file on Android, or.android.js
on iOS, or it may resolve to a generic implementation even where there’s a platform-specific one available. While the bundle may build, that’s likely to result in unexpected behaviour including runtime crashes if any of those components are used.See https://github.com/facebook/react-native/issues/36794#issuecomment-1500880284 for the workarounds we recommend until we get this fixed. (In the works with https://github.com/facebook/react-native/pull/37501 and https://github.com/facebook/metro/pull/989)
Same issue with
react-native: 0.71.7
,expo: 48.0.16
,expo-cli: 6.3.7
,eas-cli: 3.12.1
I also confirm that the workaround suggested here works for me
I’m facing the same issue with 0.70.9. Any updates?
try updating RN to 0.71.7 and expo to 48.0.15 I’m using a managed workflow too and my error is gone in these versions using hermes (wich is faster and lower app size)
also don’t forget to update your expo and eas CLIs
My app was rejected from the app store due to crashes on 16.4. Testing myself, this error is being reproduced. Is there a solution for this yet?
To note, I’ve tried switching to hermes and using the rewriteRequestUrl in metro.config.js as described above, but continue to get the DatePickerIOS errors.
I have same error with Expo.
i"m also having the same issue
Thanks really helpful
I have facing same issues on iOS, My Xcode version is Version 14.3.1 , and react-native-cli: 2.0.1 react-native: 0.69.1 this is i have in react native, i had changed the platform version in /Users/mcl-0048/Desktop/Conexus/node_modules/react-native/scripts/react_native_pods.rb on line number 401 ‘platforms’ => { ‘ios’ => ‘12.0’, }, like this then getting this issues ERROR TypeError: undefined is not an object (evaluating ‘mediaDevices.enumerateDevices’) Error: Unable to resolve module ./Libraries/Components/DatePicker/DatePickerIOS from /Users/mcl-0048/Desktop/Conexus/node_modules/react-native/index.js:
please some let me know how to resolve this issues i have tried multiple solutions but none of them are working and my client is waiting for the project delivery asap
I had this same erro… What’s the solution?
Hey folks! Can anyone check if with the latest RC, RC5, the issue is addressed?
Which metro.config.js file should I edit? If I search on my project directory I see several file for some of the packages I installed.
Hi 😃
I think you may have something else in your application causing it to crash.
The warning produced above, as annoying as it is for polluting the console, doesn’t cause an app to crash from my understanding and experience so far.
We haven’t had issues with App Store review rejections to do with this error causing any crashes whatsoever.
this error happens to me on my local machine, but… happens on a real device when I make the release to the App Store?
Worked perfectly with iOS 16.0
@AndreasLS excellent detective work, that makes a lot more sense that Xcode itself being the culprit.
Same issue Here with Xcode 14.3
Same issue with Xcode 14.3
Same issue here Xcode 14.3
same issue React Native: 0.70.5 Xcode: 14.3
I downgraded xcode version to 14.2 it helped.