Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
fix(workers): disable workers for now
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Aug 31, 2018
1 parent e81484c commit 64db490
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const CipmOpts = figgyPudding({
also: {},
dev: 'development',
development: {},
dirPacker: {},
force: {},
global: {},
ignoreScripts: 'ignore-scripts',
Expand Down Expand Up @@ -238,7 +239,7 @@ class Installer {
return next()
} else {
return BB.resolve(extract.child(
dep.name, dep, depPath, this.config, this.opts
dep.name, dep, depPath, this.opts
))
.then(() => cg.completeWork(1))
.then(() => { this.pkgCount++ })
Expand Down
51 changes: 31 additions & 20 deletions lib/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,56 @@

const BB = require('bluebird')

const npa = require('npm-package-arg')
const workerFarm = require('worker-farm')

const extractionWorker = require('./worker.js')
const figgyPudding = require('figgy-pudding')
const npa = require('npm-package-arg')
const WORKER_PATH = require.resolve('./worker.js')
let workerFarm

// Broken for now, cause too many issues on some systems.
const ENABLE_WORKERS = false

const ExtractOpts = figgyPudding({
log: {}
})

module.exports = {
startWorkers () {
this._workers = workerFarm({
maxConcurrentCallsPerWorker: 20,
maxRetries: 1
}, WORKER_PATH)
if (ENABLE_WORKERS) {
if (!workerFarm) { workerFarm = require('worker-farm') }
this._workers = workerFarm({
maxConcurrentCallsPerWorker: 20,
maxRetries: 1
}, WORKER_PATH)
}
},

stopWorkers () {
workerFarm.end(this._workers)
if (ENABLE_WORKERS) {
if (!workerFarm) { workerFarm = require('worker-farm') }
workerFarm.end(this._workers)
}
},

child (name, child, childPath, config, opts) {
child (name, child, childPath, opts) {
opts = ExtractOpts(opts)
const spec = npa.resolve(name, child.version)
const additionalToPacoteOpts = {}
if (typeof opts.dirPacker !== 'undefined') {
additionalToPacoteOpts.dirPacker = opts.dirPacker
}
const childOpts = config.toPacote(Object.assign({
let childOpts = opts.concat({
integrity: child.integrity,
resolved: child.resolved
}, additionalToPacoteOpts))
})
const args = [spec, childPath, childOpts]
return BB.fromNode((cb) => {
let launcher = extractionWorker
let msg = args
const spec = typeof args[0] === 'string' ? npa(args[0]) : args[0]
childOpts.loglevel = opts.log.level
if (spec.registry || spec.type === 'remote') {
if (ENABLE_WORKERS && (spec.registry || spec.type === 'remote')) {
if (!workerFarm) { workerFarm = require('worker-farm') }
// We can't serialize these options
childOpts.config = null
childOpts.log = null
childOpts.dirPacker = null
childOpts = childOpts.concat({
log: null,
dirPacker: null
})
// workers will run things in parallel!
launcher = this._workers
try {
Expand Down

0 comments on commit 64db490

Please sign in to comment.