[v4.1.16] Build hangs when using eas
Describe the bug
When running eas build --platform android on a new project created with npx create-expo-stack@latest --nativewind the build gets stuck on :expo-modules-core:copyReleaseJniLibsProjectOnly until it times out
Reproduction
-
Create Expo Stack template
-
npx create-expo-stack@latest --nativewind
-
-
Build
-
eas build --platform android
-
Screenshot
I had the same, I reverted back to .10 to solve for now. Your version milage may vary
Reproduction steps for a local build (without eas):
npx create-expo-stack@latest my-expo-app --expo-router --nativewind
cd my-expo-app
npx expo prebuild
cd android
./gradlew assembleRelease
Should get stuck on app:createBundleReleaseJsAndAssets. Reverting back to 4.1.10 does indeed make the problem go away, however won't work for me as that introduces other bugs that affect my app which are fixed in 4.1.12 which unfortunately also hangs the process.
Have you tried 4.1.16 ?
Yes for context I discovered the problem on 4.1.16. I haven't tested every version between 4.1.11 to 4.1.16 but as of now I have not found one that works.
Interestingly I have not been able to reproduce it more cleanly isolating the bundling process out of the build. In my case I use expo-router, so if I run the following command metro finishes its job and hangs. However, that command hangs on 4.1.10 as well which looks to me like a red herring.
npx expo export:embed --platform android --entry-file node_modules/expo-router/entry.js --bundle-output asd.js
The process that keeps it alive shows on 4.1.10, 4.1.12 & 4.1.16 as:
/usr/bin/node-20 /home/ivstiv/Projects/food-tracker-app/node_modules/nativewind/dist/metro/tailwind/v3/child.js
It's an issue with building for releasing on Android.
You can repro by going to ./android and running ./gradlew build --warning-mode all.
The result is gradle gets stuck on :app:createBundleReleaseJsAndAssets
Discovered this on version 4.1.16, same issue on 4.1.15.
Android Bundling failed 2484ms C:\Users\User\code\myapp\node_modules\expo-router\entry.js (1 module)
Error: ENOENT: no such file or directory, open 'C:\Users\User\code\myapp\node_modules\nativewind\.cache\global.css.android.css'
Error: ENOENT: no such file or directory, open 'C:\Users\User\code\myapp\node_modules\nativewind\.cache\global.css.android.css'
at Object.openSync (node:fs:573:18)
at Object.readFileSync (node:fs:452:35)
at Object.processPROD (C:\Users\User\code\myapp\node_modules\nativewind\src\metro\tailwind\v3\index.ts:52:15)
at Object.processPROD (C:\Users\User\code\myapp\node_modules\nativewind\src\metro\index.ts:48:18)
at Object.getTransformOptions (C:\Users\User\code\myapp\node_modules\react-native-css-interop\src\metro\index.ts:123:49)
at calcTransformerOptions (C:\Users\User\code\myapp\node_modules\metro\src\lib\transformHelpers.js:70:25)
at Object.getTransformFn (C:\Users\User\code\myapp\node_modules\metro\src\lib\transformHelpers.js:104:51)
at IncrementalBundler.buildGraphForEntries (C:\Users\User\code\myapp\node_modules\metro\src\IncrementalBundler.js:60:18)
at IncrementalBundler.buildGraph (C:\Users\User\code\myapp\node_modules\metro\src\IncrementalBundler.js:134:19)
at C:\Users\User\code\myapp\node_modules\metro\src\IncrementalBundler.js:172:34
Got above error on 4.1.10 on Windows.
Edit - Switching to "nativewind": "4.1.0" worked.
Unsure this is related to the specific issue above. Given that I can get it to build fine on 4.1.10 - the above error might be something different.
For me, on mac using both EAS and Xcode to build an Archive, 4.1.10 works (assuming I do not have the ^ on the version number in package) and 4.1.11 and above all get stuck on the Bundling stage.
When I get 5 mins I might try and go through the commits from 4.1.11 to help figure out a likely cause.
Could be. I can try cleaning cache and try again. This issue was there in earlier versions.
https://github.com/nativewind/nativewind/issues/591#issuecomment-1783662675
It's an issue with building for releasing on Android.
You can repro by going to
./androidand running./gradlew build --warning-mode all.The result is gradle gets stuck on
:app:createBundleReleaseJsAndAssets
thanks for digging deeper, will take a look today/tomorrow
I dug through the git history and compared it with the compiled output on npm for [email protected]. It looks like this commit is the last relevant one that affects the currently published version: https://github.com/nativewind/nativewind/commit/2fb4714d6bee8bb55b3f227243d2d20409aa699c
Inside packages/react-native-css-interop/src/metro/index.ts on line 248-ish getCSSForPlatform is called with a callback. https://github.com/nativewind/nativewind/commit/2fb4714d6bee8bb55b3f227243d2d20409aa699c#diff-6760cd3ec6b441f2e2351a1a75f911e538f5ce822d39a6cda74db6a2e9f5fad5R247
That callback happens to be the onChange used to determine whether to add --watch to the tailwind cli.. https://github.com/nativewind/nativewind/blob/fa082a2ccac30e1d54870a69e979a090d885f5c7/packages/nativewind/src/metro/tailwind/v3/index.ts#L26
If I console.log the stack and callback inside my node modules (check the debug call for location)
getCSSForPlatform(options) {
debug("Start development Tailwind CLI");
return new Promise((resolve, reject) => {
console.log("onChange", typeof options.onChange);
console.log(new Error().stack);
I am getting a very clear indication that indeed that function is being called and the onChange is a truthy value!
onChange function
Error:
at /home/ivstiv/Projects/food-tracker-app/node_modules/nativewind/src/metro/tailwind/v3/index.ts:38:17
at new Promise (<anonymous>)
at Object.getCSSForPlatform (/home/ivstiv/Projects/food-tracker-app/node_modules/nativewind/src/metro/tailwind/v3/index.ts:36:14)
at getCSSForPlatform (/home/ivstiv/Projects/food-tracker-app/node_modules/nativewind/src/metro/index.ts:64:18)
at startCSSProcessor (/home/ivstiv/Projects/food-tracker-app/node_modules/react-native-css-interop/src/metro/index.ts:248:13)
However the relevant file from react-native-css-interop has since then changed, but not republished with a new version. It now works based on an isDev check which might fix the issue at hand if a new version can be released. https://github.com/nativewind/nativewind/commit/23e41265ae85ec490db316f7def73817ec408436#diff-6760cd3ec6b441f2e2351a1a75f911e538f5ce822d39a6cda74db6a2e9f5fad5R241-R290
If anybody wants an immediate bodge because they are really pressed to get a build out with an updated nativewind, this will get you going.
Find this file: node_modules/nativewind/dist/metro/tailwind/v3/index.js
On line 12-ish you will find this:
NATIVEWIND_WATCH: options.onChange ? "true" : "false",
Change it to this and build your release:
NATIVEWIND_WATCH: "false",
don't forget to remove it afterwards.*
Seems to be fixed with v4.1.17 for me
Nice one guys! Can confirm: ├─ [email protected] └─ [email protected] works for me as well.
I can also Confirm. It's working for me too.
Thank you fixing this.
Nice one guys! Can confirm: ├─ [email protected] └─ [email protected] works for me as well.
Doesn't seem to be working for me. I get the following error: node_modules/react-native-css-interop/.cache/android.js is not computed.
[RUN_GRADLEW] > Task :app:createReleaseUpdatesResources FAILED
[RUN_GRADLEW] Error: @build-script-error-begin
[RUN_GRADLEW] Error loading assets JSON from Metro. Ensure you've followed all expo-updates installation steps correctly. SHA-1 for file /tmp/user/eas-build-local-nodejs/ef99367b-63a0-4233-b5e3-cfb13fb1a02c/build/node_modules/react-native-css-interop/.cache/android.js is not computed.
[RUN_GRADLEW] Potential causes:
[RUN_GRADLEW] 1) You have symlinks in your project - watchman does not follow symlinks.
[RUN_GRADLEW] 2) Check `blockList` in your metro.config.js and make sure it isn't excluding the file path.
[RUN_GRADLEW] @build-script-error-end
[RUN_GRADLEW] at createManifestForBuildAsync (/tmp/user/eas-build-local-nodejs/ef99367b-63a0-4233-b5e3-cfb13fb1a02c/build/node_modules/expo-updates/utils/build/createManifestForBuildAsync.js:44:15)
[RUN_GRADLEW] at processTicksAndRejections (node:internal/process/task_queues:105:5)
[RUN_GRADLEW] at async Promise.all (index 0)
[RUN_GRADLEW] at async /tmp/user/eas-build-local-nodejs/ef99367b-63a0-4233-b5e3-cfb13fb1a02c/build/node_modules/expo-updates/utils/build/createUpdatesResources.js:26:5
[RUN_GRADLEW] FAILURE: Build failed with an exception.
[RUN_GRADLEW] * What went wrong:
[RUN_GRADLEW] Execution failed for task ':app:createReleaseUpdatesResources'.
[RUN_GRADLEW] > Process 'command 'node'' finished with non-zero exit value 1
[RUN_GRADLEW] * Try:
[RUN_GRADLEW] > Run with --stacktrace
[RUN_GRADLEW] option to get the stack trace.
[RUN_GRADLEW] > Run with --info or --debug option to get more log output.
[RUN_GRADLEW] > Run with --scan to get full insights.
[RUN_GRADLEW] > Get more help at https://help.gradle.org.
[RUN_GRADLEW] BUILD FAILED in 7m 40s
[RUN_GRADLEW] Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
[RUN_GRADLEW] You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
[RUN_GRADLEW] For more on this, please refer to https://docs.gradle.org/8.8/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
[RUN_GRADLEW] 1945 actionable tasks: 1945 executed
[RUN_GRADLEW] Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
Build failed
Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
npx exited with non-zero code: 1
Error: build command failed.
I've tried removing node_modules, prebuilding, and then ./gradlew build from android as well as eas build --clear-cache, all resulting in the same error seen above.
Anyone else facing the same issue?
UPDATE:
Removing expo-updates fixed the issue
FYI: I see the SHA-1 issue but am not using EAS.
I do have Microsoft code-push and Sentry. Also, it only happens during CI. I can't replicate it locally.
Fixed in 4.1.18. You are still seeing this isue please create a new issue with a reproduction including the steps used in CI