Workaround for cb() never called errors

Problem:

Intermittent "cb() never called!" errors on npm installs for platform.
This is likely due to a race condition on installing OS-specific bits that are built during time of install. When more than one compilation takes place at one time, this error can occur.

Workaround:

Detect the error and re-run the install. (When retrying, one or all of the bits have been compiled. So running it again just finishes the install.)
This commit is contained in:
Ben Patterson
2016-11-10 14:54:53 -05:00
parent 695e5c0751
commit f52e3cf830

View File

@@ -8,7 +8,7 @@ import os
import re
import sys
from paver.easy import sh, task
from paver.easy import sh, task, BuildFailure
from .utils.envs import Env
from .utils.timer import timed
@@ -132,10 +132,19 @@ def node_prereqs_installation():
"""
Configures npm and installs Node prerequisites
"""
cb_error_text = "Subprocess return code: 1"
sh("test `npm config get registry` = \"{reg}\" || "
"(echo setting registry; npm config set registry"
" {reg})".format(reg=NPM_REGISTRY))
sh('npm install')
# Error handling around a race condition that produces "cb() never called" error. This
# ought to disappear when we upgrade npm to 3 or higher. TODO: clean this up when we do that.
try:
sh('npm install')
except BuildFailure, error_text:
if cb_error_text in error_text:
print "npm install error detected. Retrying..."
sh('npm install')
def python_prereqs_installation():