question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React Native with hermes-js-engine struggling to build release version

See original GitHub issue

Small description:

There are some new RegExp(/^.../) statements used in the aws-sdk source code that hermes-js cannot parse (is not yet able to parse) and therefore leads to unsuccessful (failed) builds. 20210926_005914 After some quick search (using grep -r --exclude=\*map\* --exclude=\*min\* "new RegExp(/^" ./node_modules), I found that these regular expressions are located in @aws-sdk/smithy-client/dist/cjs/date-utils.js file.

If I remove all the usages of the @aws-sdk everything works as expected.

My environment:

SDK version number

@aws-sdk/client-location@3.34.0

Is the issue in the browser/Node.js/ReactNative?

ReactNative (only on release builds)

Details of the browser/Node.js/ReactNative version

Output of yarn react-native info:

info Fetching system and libraries information...
System:
    OS: Linux 5.14 Arch Linux
    CPU: (4) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
    Memory: 383.89 MB / 15.06 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.9.1 - /tmp/yarn--1632607664796-0.5372215827563698/node
    Yarn: 1.22.11 - /tmp/yarn--1632607664796-0.5372215827563698/yarn
    npm: 7.24.1 - ~/.nvm/versions/node/v16.9.1/bin/npm
    Watchman: 20210523.214641.0 - /usr/local/bin/watchman
  SDKs:
    Android SDK:
      API Levels: 29, 30, 31
      Build Tools: 28.0.3, 29.0.2, 30.0.2, 31.0.0, 31.0.0
      System Images: android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
      Android NDK: 22.1.7171670
  IDEs:
    Android Studio: AI-203.7717.56.2031.7678000
  Languages:
    Java: 1.8.0_292 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2
    react-native: 0.65.1 => 0.65.1
  npmGlobalPackages:
    *react-native*: Not Found
Done in 4.63s.
yarn react-native info  9.60s user 0.58s system 206% cpu 4.927 total

Steps to reproduce

Install @aws-sdk/client-location and just try to use it. Development builds are successful, but the release ones are doomed. Of course, don’t forget to enable hermes engine.

Observed behavior

Image above (in the description)

Expected behavior

At least a successful release build would be nice.

Extra text for search results (if others get stuck)

/home/darapsas/Projects/inhyr-mobile/android/app/build/generated/assets/react/release/index.android.bundle:372076:28: error: Invalid regular expression: Quantifier has nothing to repeat
  var RFC3339 = new RegExp(/^(?<Y>\d{4})-(?<M>\d{2})-(?<D>\d{2})[tT](?<H>\d{2}):(?<m>\d{2}):(?<s>\d{2})(?:\.(?<frac>\d+))?[zZ]$/);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/darapsas/Projects/inhyr-mobile/android/app/build/generated/assets/react/release/index.android.bundle:372101:32: error: Invalid regular expression: Quantifier has nothing to repeat
  var IMF_FIXDATE = new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?<D>\d{2}) (?<M>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?<Y>\d{4}) (?<H>\d{2}):(?<m>\d{2}):(?<s>\d{2})(?:\.(?<frac>\d+))? GMT$/);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/darapsas/Projects/inhyr-mobile/android/app/build/generated/assets/react/release/index.android.bundle:372102:33: error: Invalid regular expression: Quantifier has nothing to repeat
  var RFC_850_DATE = new RegExp(/^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?<D>\d{2})-(?<M>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(?<Y>\d{2}) (?<H>\d{2}):(?<m>\d{2}):(?<s>\d{2})(?:\.(?<frac>\d+))? GMT$/);
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/darapsas/Projects/inhyr-mobile/android/app/build/generated/assets/react/release/index.android.bundle:372103:29: error: Invalid regular expression: Quantifier has nothing to repeat
  var ASC_TIME = new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?<M>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?<D> [1-9]|\d{2}) (?<H>\d{2}):(?<m>\d{2}):(?<s>\d{2})(?:\.(?<frac>\d+))? (?<Y>\d{4})$/);
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
AllanZhengYPcommented, Nov 11, 2021

@Darapsas @StampixSMO

This issue should be fixed in https://github.com/aws/aws-sdk-js-v3/pull/3008, it will be out in next release!

1reaction
StampixSMOcommented, Sep 27, 2021

This is most likely due to Hermes not supporting named capturing groups: https://github.com/facebook/hermes/blob/main/doc/RegExp.md

To resolve this, named capturing groups should not be used.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Hermes - React Native
React Native comes with a bundled version of Hermes. We will be building a version of Hermes for you whenever we release a...
Read more >
React Native (Android) - Failed to transform hermes-debug.aar
The problem is definitely due to hermes, but I had to tune some other things to properly update my react-native application and let...
Read more >
How to enable Hermes Engine in an existing react native app
First, ensure you're using at least version 0.60.4 of React Native. If you have an existing app based on an earlier version of...
Read more >
Speeding up your React Native App with Hermes - DigitalOnUs
Hermes is a helper created by Facebook engineers that works specially for Android. The objective of this engine is to increase the startup...
Read more >
Optimizing your Android Build for React Native - Echobind
Jan 21, 2020 | Are you familiar with the Hermes Engine for Android that came out with the release of React Native 0.61?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found