Skip to content

react-native chrono - Invalid RegExp: Quantifier has nothing to repeat, js engine: hermes #483

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

Closed
sajjad-karimi opened this issue Dec 5, 2022 · 8 comments

Comments

@sajjad-karimi
Copy link

I've used chrono-node in react-native app and when I import chrono-node in app with hermes engine . I get the following error:

SyntaxError: Invalid RegExp: Quantifier has nothing to repeat, js engine: hermes

@wanasit
Copy link
Owner

wanasit commented Dec 25, 2022

Hello @sajjad-karimi sorry for my slow reply. I'm not aware of the Hermes engine.

Will try to see if we can support that engine.

@sanjeev-karat-zs0194
Copy link

We have a similar issue too. Do we have any workaround/suggestions?

@Nantris
Copy link

Nantris commented Jan 18, 2023

@wanasit the issue is related to this one: facebook/hermes#696

I tried using the core-js polyfill: core-js/proposals/regexp-named-groups - but then it just throws with Invalid RegExp: Invalid escape (Possibly related to this though I've never heard of unnecessary escapes breaking code execution) - (in this file: https://github.com/wanasit/chrono/blob/master/src/locales/ru/parsers/RUTimeUnitWithinFormatParser.ts)

The issue specifically is due to the use of named capture groups in the ZH and RU locale files, but I've not found any way to remedy the issue so far.

My only remaining idea is to use patch-package, which I guess I'll probably need to try.

@Nantris
Copy link

Nantris commented Jan 19, 2023

Confirmed that commenting out the RU and ZH parsers from the dist/index.js resolves my issue.

@Nantris
Copy link

Nantris commented Feb 24, 2023

Should be fixed in future versions of Hermes if the "completed" status of this issue is anything to go by: facebook/hermes#696

@wanasit wanasit added the bug label Mar 18, 2023
@wanasit
Copy link
Owner

wanasit commented Mar 18, 2023

Yes. I have checked out the latest build for the Hermes engine and it compiles the RegExp correctly now. This should make its way to react native app soon.

@mfbx9da4
Copy link

I tried commenting out ZH and RU and adding the core-js polyfill and my error turned into:

Maximum call stack size exceeded
    at module.exports (/.../node_modules/core-js/internals/is-regexp.js:12:9)

@wanasit
Copy link
Owner

wanasit commented Nov 19, 2023

As replied in #527. Please try update to Chrono v2.7.3
https://github.com/wanasit/chrono/releases/tag/v2.7.3

I have fixed the issue by switching to lazy-loading/creating RegEx patterns. In the longer term, we can only wait for Hermes Engine to support those patterns.

I'm closing this issue. Please comment on #527 or create a new issue for Hermes engine.

@wanasit wanasit closed this as completed Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants