Skip to content

npm run build silently fails on OOM #1493

Description

@brandones

Description

When running npm run build, if the system runs out of memory...

Expected behavior

It should exit with a non-zero return code.

Actual behavior

The process exits return code 0.

Environment

  1. npm ls react-scripts: 0.7.0
  2. node -v: v6.9.5
  3. npm -v: 3.10.10

Then, specify:

  1. Operating system: Ubuntu 16.04
  2. Browser and version: n/a

Reproducible Demo

Try building on a tiny VM.

See #1026

Activity

  1. gaearon commented on Feb 7, 2017

    @gaearon
    Contributor

    Agreed it’s an issue, do you have any idea how to solve this?

  2. brandones commented on Feb 7, 2017

    @brandones
    ContributorAuthor

    Well, it looks like react-scripts build runs node build.js, and when you send SIGTERM to the latter process (as happens with an OOM) it exits silently. Default behavior for node on SIGTERM (aka signal 15) is to exit 15. So this script is probably catching SIGTERM somewhere and exiting "gracefully."

  3. brandones commented on Feb 7, 2017

    @brandones
    ContributorAuthor

    Adding

     process.on('SIGTERM', function () {
       process.exit(15);
     });
    

    to the end of react-scripts/scripts/build.js fixes the problem. I'll add a couple more signals, console.log an error message, and submit a pull request -- cool? Is there a cleanup hook I should call?

  4. gaearon commented on Feb 7, 2017

    @gaearon
    Contributor

    @brandones Sounds great, thanks!

  5. added this to the 0.9.0 milestone on Feb 9, 2017
  6. gaearon commented on Feb 11, 2017

    @gaearon
    Contributor

    Can we consider this resolved by #1496?

  7. gaearon commented on Feb 11, 2017

    @gaearon
    Contributor

    Going to close in hope it’s resolved but please reopen if not.

  8. locked and limited conversation to collaborators on Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions