0

I am facing this issue in Visual studio app center (CI) when building ios react-native app.I have gone through the issues in github and other stackoverflow questions regarding this.All of them suggested to change node memory like this. --expose-gc --max_old_space_size=32000 .But I don't have idea how change that in CI.

I tried one method which is, I found below bundling command in node_modules/react-native/scripts/react-native-xcode.sh

$NODE_BINARY $CLI_PATH bundle \
  --entry-file "$ENTRY_FILE" \
  --platform ios \
  --dev $DEV \
  --reset-cache \
  --bundle-output "$BUNDLE_FILE" \
  --assets-dest "$DEST" 

So In appcenter-pre-build.sh I wrote code which will add --expose-gc --max_old_space_size=32000 to the above command like below

$NODE_BINARY --expose-gc --max_old_space_size=32000 $CLI_PATH bundle \
  --entry-file "$ENTRY_FILE" \
  --platform ios \
  --dev $DEV \
  --reset-cache \
  --bundle-output "$BUNDLE_FILE" \
  --assets-dest "$DEST"

and tried even though I am getting same error.

 transform[stdout]: <--- JS stacktrace --->
transform[stdout]: 
transform[stdout]: ==== JS stack trace =========================================
transform[stdout]: 
transform[stdout]: Security context: 0x194baa3cf781 <JS Object>
transform[stdout]:     1: popContext [/Users/vsts/agent/2.127.0/work/1/s/node_modules/babel-traverse/lib/path/context.js:~222] [pc=0xb87791150c3] (this=0x399c406adfc9 <a NodePath with map 0x1b8e272b61a1>)
transform[stdout]:     2: visitQueue [/Users/vsts/agent/2.127.0/work/1/s/node_modules/babel-traverse/lib/context.js:~114] [pc=0xb8778a8efd2] (this=0xa337d831709 <a TraversalContext with map 0x1b8e272b5d81>,queue=0xa337d831751 <JS ...
transform[stdout]: 
transform[stderr]: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
transform[stderr]:  1: node::Abort() [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]:  2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]:  3: v8::Utils::ReportApiFailure(char const*, char const*) [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]:  4: v8::Utils::ApiCheck(bool, char const*, char const*) [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]:  5: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]:  6: v8::internal::Factory::NewRawOneByteString(int, v8::internal::PretenureFlag) [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]:  7: v8::internal::Factory::NewStringFromOneByte(v8::internal::Vector<unsigned char const>, v8::internal::PretenureFlag) [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]:  8: v8::internal::Factory::NumberToString(v8::internal::Handle<v8::internal::Object>, bool) [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]:  9: v8::internal::Object::ToString(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>) [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]: 10: v8::internal::Object::ConvertToName(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>) [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]: 11: v8::internal::LookupIterator::PropertyOrElement(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, bool*, v8::internal::LookupIterator::Configuration) [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]: 12: v8::internal::Runtime::GetObjectProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]: 13: v8::internal::Runtime_KeyedGetProperty(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/Cellar/node@6/6.12.3/bin/node]
transform[stderr]: 14: 0xb87779092a7
transform[stdout]: 
transform[stdout]: <--- Last few GCs --->
Dinesh Chitta
  • 670
  • 8
  • 23

1 Answers1

0

My solution was to add an appcenter-post-clone.sh script that increased the node memory.

#!/usr/bin/env bash
export NODE_BINARY='node --expose-gc --max_old_space_size=4096'

I believe upgrading the node version may also be a solution.

Corey
  • 1,010
  • 9
  • 17