microsoft / appcenter-cli

Command-line Interface (CLI) for Visual Studio App Center
https://appcenter.ms/
MIT License
582 stars 235 forks source link

React Native bundling fails but CLI still proceeds to release #911

Closed RishabhKarnad closed 5 months ago

RishabhKarnad commented 4 years ago

When running the codepush release-react subcommand, if there is a failure when creating the React Native bundle due to a lack of heap space in the node process, a release is still created.

Steps to reproduce:

  1. Use CODE_PUSH_NODE_ARGS to reduce node max_old_space_size to a small enough number, so that the bundler runs out of memory. e.g. export CODE_PUSH_NODE_ARGS='--max_old_space_size=256'
  2. Run appcenter codepush release-react. e.g. appcenter codepush release-react -a <appName> -d <deployment>

Expected result

Since the bundler fails, a release should not be created

Actual result

A release is created. This causes CI builds to pass. The size of the bundle is only a few bytes and results in a crash and rollback when installed in the RN app.

react-native version

0.62

react-native-code-push version

6.2.0

Example logs

+ appcenter codepush release-react -a [REDACTED] --token [REDACTED] --quiet --sourcemap-output --output-dir ./build-ios --deployment-name Staging
Detecting ios app version:
Using the target binary version value "1.0.0" from [REDACTED].
Running "react-native bundle" command:
node node_modules/.bin/react-native bundle --assets-dest build-ios/CodePush --bundle-output build-ios/CodePush/main.jsbundle --dev false --entry-file index.js --platform ios --sourcemap-output build-ios/CodePush/main.jsbundle.map
Welcome to React Native!
                Learn once, write anywhere

<--- Last few GCs --->
[3170:0x102862000]   616509 ms: Mark-sweep 1321.7 (1444.6) -> 1306.3 (1445.1) MB, 3073.1 / 0.0 ms  (average mu = 0.122, current mu = 0.042) allocation failure scavenge might not succeed
[3170:0x102862000]   620305 ms: Mark-sweep 1321.4 (1445.6) -> 1306.1 (1445.1) MB, 3609.9 / 0.0 ms  (average mu = 0.085, current mu = 0.049) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
    0: ExitFrame [pc: 0x30de0465be3d]
Security context: 0x0e3069c9e6c1 <JSObject>
    1: quote(aka quote) [0xe304e3098d1] [0x0e30a94026f1 <undefined>:~228] [pc=0x30de04664dde](this=0x0e30a94026f1 <undefined>,word=0x0e300de5f6e1 <String[1]: (>)
    2: OutputStream(aka OutputStream) [0xe30a2bc3ac9] [0x0e30a94026f1 <undefined>:~5547] [pc=0x30de070269b3](this=0x0e30a94026f1 <undefined>,options=0x0e30a94026f1 <undefined>)
    3: /* anonymous *...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x100d68631 node::Abort() (.cold.1) [/Users/vagrant/.nvm/versions/node/v10.21.0/bin/node]
2: 0x10003b124 node_module_register [/Users/vagrant/.nvm/versions/node/v10.21.0/bin/node]
...

Releasing update contents to CodePush:
Successfully released an update containing the "build-ios/CodePush" directory to the "Staging" deployment of the [REDACTED] app.
+ exit 0

Release details in AppCenter dashboard

Screenshot 2020-06-11 at 3 02 39 AM
Krasavinigor commented 4 years ago

Hi @RishabhKarnad! I opened PR: https://github.com/microsoft/appcenter-cli/pull/1115 with a fix for this issue. Take a look if you have time.

hpello commented 2 years ago

Hello,

We also experience this issue for some builds in our CI. Sometimes, the builds silently fails, and the faulty bundle is sent to AppCenter.

I think I know where the issue comes from:

The check to assert if the subprocess has failed is: https://github.com/microsoft/appcenter-cli/blob/ada80998fdbd46657ea9cb1b8d04d3264a93953a/src/commands/codepush/lib/react-native-utils.ts#L342

However, if the process is killed, exitCode will be null (and signal will be non-null)

References:

hpello commented 2 years ago

Opened #2004 as an attempt to fix this issue.