Skip to content

child_process: child_process.spawn ENOMEM on Windows  #25484

@bcoe

Description

@bcoe
  • Version: 11
  • Platform: Windows Server 2016
  • Subsystem: child_process

Windows Server 2016 appears to run into memory issues when spawning multiple subprocesses.

Here's the test in question in nyc:

const path = require('path')
const assert = require('assert')
const {spawnSync} = require('child_process')
const time = process.hrtime()
const workerPath = path.join(__dirname, './cache-collision-worker.js')

function doFork (message) {
  const output = spawnSync(process.execPath, [workerPath, String(time[0]), String(time[1]), message])
  assert.equal(output.status, 0, 'received non-zero exit code ' + output.status)
}

doFork('foo')
doFork('bar')
doFork('baz')
doFork('quz')
doFork('nada')

which spawns the fairly boring subprocess:

var assert = require('assert')

var start = [
  parseInt(process.argv[2], 10),
  parseInt(process.argv[3], 10)
]

var message = process.argv[4]

var diff = process.hrtime(start)

while (diff[0] * 1e9 + diff[1] < 3e9) {
  diff = process.hrtime(start)
}


assert.strictEqual(require('./cache-collision-target')(message), message === 'nada' ? undefined :  'this is a ' + message)

//assert.strictEqual(process.env.NYC_CWD, __dirname)

which in turn requires:

module.exports = function (foo) {
  if (foo === 'foo') {
    return 'this is a foo'
  }
  if (foo === 'bar') {
    return 'this is a bar'
  }
  if (foo === 'baz') {
    return 'this is a baz'
  }
  if (foo === 'quz') {
    return 'this is a quz'
  }
}

I've tried using both spawn and spawnSync and the issue crops up in both cases. I also note that this behavior is new to Node 11 (labeled as node in the image included):

screen shot 2019-01-13 at 6 52 05 pm

At a glance, this issue seems similar to #25382; but I note that tests run fine on Node 8 and Node 10.

@nodejs/process

Metadata

Metadata

Labels

child_processIssues and PRs related to the child_process subsystem.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.windowsIssues and PRs related to the Windows platform.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions