mattermost-mobile: Node crashes during build

Summary

When trying to build 1.13.1 on an F-Droid build VM, Node crashes during bundleReleaseJsAndAssets.

Steps to reproduce

The build recipe is available here but except for the patching, we are basically running this:

make pre-run
gradle assembleRelease

Expected behavior

The app should build correctly.

Observed behavior

The build fails with this error:

DEBUG: buildserver > Execution failed for task ':app:bundleReleaseJsAndAssets'.
DEBUG: buildserver > > Process 'command 'node'' finished with non-zero exit value 137

Possible fixes

This error is probably caused by a lack of memory (our build VMs have 2 GB of RAM and I can’t reproduce the issue on my computer with 12 GB of RAM). Is there a way to limit the amount of memory used by the React Native build script?

(Also, I can’t reproduce this with 1.11.0 so I suppose recent versions started to use more ressources.)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

I found a way to limit the amount of memory Node can use:

--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -75,7 +75,8 @@ import com.android.build.OutputFile
 project.ext.react = [
     entryFile: "index.js",
     bundleCommand: "ram-bundle",
-    bundleConfig: "packager-config.js"
+    bundleConfig: "packager-config.js",
+    nodeExecutableAndArgs: ["node", "--max-old-space-size=2048"]
 ]
 
 apply from: "../../node_modules/react-native/react.gradle"

I still wish this could be done automatically but at least we can build the app now 🙂