App doesn’t use second packager
I have this issue both with an internal app, and with the example app, after updating react-native.
git clone [email protected]:fabriciovergal/react-native-workers.git
cd react-native-workers/example
npm i && npm i [email protected]
# In separate terminals:
react-native start
react-native start --port 8082
react-native run-android
In no case does anything actually trigger the second packager: both index.android.js and index.worker.js are packaged by the first packager, listening on port 8081. This causes issues when I try to run the debugger: if I launch the Chrome debugger, there seems about a 50-50 chance that it will show the app bundle or the worker bundle, respectively.
Note: I’m not having this problem with the iOS version of the same internal app (I had some different issues with the example, but since the bug I’m concerned with here doesn’t occur, and I know virtually dick all about Apple development, those aren’t relevant).
I think i have an issue due to the same thing that you mentioned. I just try the sample code provided in ReadMe and it sometimes works sometimes not. So, did you give up on this library or could you find a way?
I’ve stopped using this library, so I’m afraid I’m of no further help. (I wouldn’t call it giving up on it, as such—we migrated some functionality to native extensions rather than JS and had no further need for asynchronous JS execution.)
all right, thanks for the reply!
I also run into this issue on Android (no issues on iOS)
While the single packager works fine for the example app, in my own app it results in strange undefined errors when I try to import third party libraries (such as react-native-sqlite-storage in my case). It seems that there is a related bug causing packager to fail to resolve certain modules in the index.worker.js.
As it turns out, the worker has no access to anything on NativeModules by default on android, they'd need to be configured explicitly. Looking through the Java code it looks like methods are already in place to allow passing in Native Modules, there just needs to be some more wiring put in place when creating the worker