hermes: RangeError: Maximum regex stack depth reached
Description
Hello there, I received an error in production with the error of RangeError: Maximum regex stack depth reached and I wanted to know what is the possible reasons that throw this range error as I checked the code from the call and I don’t see any regex usages. Maybe the regex are not being recycled?
Stacktrace
Follow stack trace of production, sorry but Sentry was not applying the source maps to RN 62 for the moment:
RangeError: Maximum regex stack depth reached
at test(app:///native)
at anonymous(app:///index.android.bundle:1:1961518)
at anonymous(app:///index.android.bundle:1:1821552)
at find(app:///native)
at anonymous(app:///index.android.bundle:1:1821489)
at value(app:///index.android.bundle:1:1817528)
at Ba(app:///index.android.bundle:1:197310)
at anonymous(app:///index.android.bundle:1:286362)
at un(app:///index.android.bundle:1:164135)
at Qa(app:///index.android.bundle:1:195963)
at Ia(app:///index.android.bundle:1:190606)
at anonymous(app:///index.android.bundle:1:164544)
at anonymous(app:///index.android.bundle:1:286362)
at un(app:///index.android.bundle:1:164135)
at dn(app:///index.android.bundle:1:164397)
at fn(app:///index.android.bundle:1:164291)
at Pe(app:///index.android.bundle:1:210309)
at Re(app:///index.android.bundle:1:158454)
at Ie(app:///index.android.bundle:1:158801)
at receiveEvent(app:///index.android.bundle:1:204317)
at apply(app:///native)
at value(app:///index.android.bundle:1:116687)
at anonymous(app:///index.android.bundle:1:115217)
at value(app:///index.android.bundle:1:116284)
at value(app:///index.android.bundle:1:115175)
Checking the bundle we can find that Me is has registerEvent function return value.
var ze="function"==typeof Symbol&&Symbol.for,Me=receiveEvent(app:///index.android.bundle:1:204317)ze?Symbol.for("react.element"):60103,Ae=ze?Symbol.for("react.portal"):60106,De=ze?Symbol.for("react.fragment"):60107,Fe=ze?Symbol.for("react.strict_mode"):60108,Oe=ze?Symbol.for("react.profiler"):60114,We=ze?Symbol.for("react.provider"):60109,je=ze?Symbol.for("react.context"):60110,He=ze?Symbol.for("react.concurrent_mode"):60111,Le=ze?Symbol.for("react.forward_ref"):60112,Qe=ze?Symbol.for("react.suspense"):60113,Be=ze?Symbol.for("react.suspense_list"):60120,Ve=ze?Symbol.for("react.memo"):60115,Ye=ze?Symbol.for("react.lazy"):60116;ze&&Symbol.for("react.fundamental"),ze&&Symbol.for("react.responder"),ze&&Symbol.for("react.scope");
Checking the IE call in stack trace I found:
function Ie(e,t,n){var r,i=n||Ne,a=xe(e);r=i.target,Re(function(){for(var e=r,n=null,l=0;l<m.length;l++){var o=m[l];o&&(o=o.extractEvents(t,a,i,e,1))&&(n=I(n,o))}if(null!==(e=n)&&(z=I(z,e)),e=z,z=null,e){if(U(e,M),z)throw Error("processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.");if(E)throw e=x,E=!1,x=null,e}})}u.RCTEventEmitter.register({receiveEvent:function(e,t,n){Ie(e,t,n)},receiveTouches:function(e,t,n){if("topTouchEnd"===e||"topTouchCancel"===e){for(var r=[],i=0;i<n.length;i++){var a=n[i];r.push(t[a]),t[a]=null}for(i=n=0;i<t.length;i++)null!==(a=t[i])&&(t[n++]=a);t.length=n}else for(r=[],i=0;i<n.length;i++)r.push(t[n[i]]);for(n=0;n<r.length;n++){(i=r[n]).changedTouches=r,i.touches=t,a=null;var l=i.target;null===l||void 0===l||1>l||(a=l),Ie(a,e,i)}}})
and inside it we can see that there is an issue on processEventQueue "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented."
Going further I found Ia
function Ia(e){var t=e.lastExpiredTime;if(t=0!==t?t:1073741823,e.finishedExpirationTime===t)Qa(e);else{if((48&ea)!==Bi)throw Error("Should not already be working.");if(Ya(),e===ta&&t===ra||za(e,t),null!==na){var n=ea;ea|=Yi;for(var r=Aa();;)try{Oa();break}catch(t){Ma(e,t)}if(En(),ea=n,Li.current=r,ia===$i)throw n=aa,za(e,t),dl(e,t),Ra(e),n;if(null!==na)throw Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.");e.finishedWork=e.current.alternate,e.finishedExpirationTime=t,ta=null,Qa(e),Ra(e)}}return null}
And then I found Qa and Ba
function Qa(e){var t=ln();return un(99,Ba.bind(null,e,t)),null}
Going from the path that can be the issue of registerEvent, in a RecyclerView I use a onClickListener for each item that is like:
movementButton.setOnClickListener {
// as there will be header in the list, probably it will show the position + 1 of relative to the header
movementListViewInstance.onClickMovement(movementItem.id, layoutPosition)
}
and inside the onClickMovement I have:
fun onClickMovement(id: String, index: Int) {
val event = Arguments.createMap()
val correctIndex : Int = movementListManager.cachedMovementList.indexOfFirst { it.id == id }
event.putString("id", id)
event.putInt("listIndex", index)
event.putInt("index", correctIndex)
reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(getId(), "topMovementPress", event)
}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (5 by maintainers)
I got this issue from sentry(email validation) : RangeError: Maximum regex stack depth reached
Steps to fix: change regex from :
/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w+)+$/;to :
/^[\w-.]+@([\w-]+.)+[\w-]{2,4}$/Same issue with react native version 70.6 on calling below function. Working well after disabling hermes.
Happens on both ios & android.