statelyai / xstate

Actor-based state management & orchestration for complex app logic.
https://stately.ai/docs
MIT License
26.51k stars 1.22k forks source link

Bug: Importing Xstate in a React-Native android project errors #4897

Closed kapir closed 1 month ago

kapir commented 1 month ago

XState version

XState version 5

Description

Importing Xstate in a React-Native android project. When doing so I am getting a "Unexpected token =" Error, there is no stack trace or similar. This is using JSCRuntime.

The error seems to occure while loading the bundle, as Metro itself does not show the error (Unless xstate is added with fast refresh). The bundle is never ran, there is atleast no input showing that.

Log output from phone: 2024-05-15 10:09:25.188 18741-23728 unknown:ReactNative com.heime.app E Exception in native call from JS com.facebook.react.devsupport.JSException: Unexpected token '=' at com.facebook.jni.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) at android.os.Looper.loop(Looper.java:250) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:234) at java.lang.Thread.run(Thread.java:923) Caused by: com.facebook.jni.CppException: Unexpected token '=' no stack ... 7 more 2024-05-15 10:09:25.188 18741-23728 ReactNativeJNI com.heime.app E Attempting to call JS function on a bad application bundle: HMRClient.setup() 2024-05-15 10:09:25.190 18741-23728 unknown:ReactNative com.heime.app E Exception in native call java.lang.RuntimeException: Attempting to call JS function on a bad application bundle: HMRClient.setup() at com.facebook.jni.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) at android.os.Looper.loop(Looper.java:250) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:234) at java.lang.Thread.run(Thread.java:923) 2024-05-15 10:09:25.190 18741-23728 ReactNativeJNI com.heime.app E Attempting to call JS function on a bad application bundle: AppRegistry.runApplication() 2024-05-15 10:09:25.192 18741-23728 unknown:ReactNative com.heime.app E Exception in native call java.lang.RuntimeException: Attempting to call JS function on a bad application bundle: AppRegistry.runApplication() at com.facebook.jni.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) at android.os.Looper.loop(Looper.java:250) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:234) at java.lang.Thread.run(Thread.java:923)

Expected result

Everything should just work.

Actual result

App is never loading metro bundle.

Reproduction

After investigating the issue for some time, i do not have time to reproduce it at this moment.

Additional context

No response

davidkpiano commented 1 month ago

Unfortunately, we cannot be sure what is causing this issue without a proper reproduction, especially an error as vague as Unexpected token =. XState does compile from TS to JS properly without errors, so maybe the issue is on the React Native side?

I will reopen this when a reproduction is available.