New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React-Native Release Builds, Deep Crash when changing locales #5252
Comments
The referenced lines are "automatically" trying to require modules at runtime, but the loading locales docs indicate that if you're using a Package Manager like JSPM, you can load locales by Ultimately, our import lines looked like this: import moment from "moment";
import "moment/min/locales"; // Import all moment-locales -- it's just 400kb
import "moment-timezone"; The exact implementation of In react-native, there are also several different flavors of Release-mode JavaScript Bundling, including all-in-one-file, all-in-separate-files, and RAM Bundles. Each of these also change how require works. Debug |
My Fix Proposals:A. Delete the |
I'd be happy to implement any of these options if a maintainer can point me at which one they would like me to implement, and for Proposals B/C help me refine which exact implementation they would be inclined to accept! |
@marwahaha -- not sure what the process is for Moment. Would you have an opinion on my fix proposals? I'd be happy to implement a PR once I get some advice on which route might be acceptable to contributors/maintainers? |
if anyone meets such errors as "can not find module './locale/xxx' in react-native production build", try to import the locale files manually. eg: import * as zh from 'moment/locale/zh-cn'; As far as I know, dynamic require is not supported in the Metro packager, which causes such errors. |
I wanted to drop ` import moment from './moment'; export { moment, hijri } The import statement change to: Do the same for all components that depend on moment. |
@fbartho thank you so much for your resume and solution. @ichernev I noticed that your fix for it was reverted by 2e26863#diff-0d89587f1f4d4ddf3b0f2727eaed1156f378a435748c74d5440f9a79bc3f2c62 do you have a plan to fix this major issue? at least for people that use moment in react native it is. thank a lot guys |
Still happens, @ichernev do you have any plan to include this fix in a future release? |
When using react-native 0.59.10, and setting the locale for momentJS, we caught a super brutal crash for our release-builds only. This crash wasn't reproducible for us with the debugger attached. This crash occurred for us both on iOS & Android. try-catch statements wrapping all moment usage did not catch the crash!
To Reproduce
["fr-CA", "en-US", "fr", "en"]
moment.locale(localeCandidate)
inside a try-catch block, the Application still crashes on this line⁇This was a crash-on-launch but only for Release builds!! This made it super tricky to extract useful error messages / logging.
We saw the following error messages via our Bugsnag integration & System Console Logging
Exception in HostFunction: Error loading module0from RAM Bundle: unspecified iostream_category error
Exception in HostFunction: Module not found: 0
Requiring unknown module "./locale/en-us".
-- but strangely, this error was not being processed in a timely manner. Possibly a react-native / bugsnag issue.moment/moment.js
Lines 1852 to 1853 in 96d0d67
Which I believe comes from here:
moment/src/lib/locale/locales.js
Lines 55 to 56 in 6a06e7a
Workaround: Commenting out those two lines halted the crash!
Expected behaviors
require()
in Release)Smartphone (please complete the following information):
Moment-specific environment
Please run the following code in your environment and include the output:
Output:
Additional context
Related Tickets
The text was updated successfully, but these errors were encountered: