Skip to content

child_process: child_process.spawn ENOMEM on Windows  #25484

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

Activity

  1. added
    child_processIssues and PRs related to the child_process subsystem.
    on Jan 14, 2019
  2. bcoe commented on Jan 14, 2019

    @bcoe
    ContributorAuthor

    attempts to dig further into this issue can be found here: istanbuljs/nyc#967

  3. bzoz commented on Jan 17, 2019

    @bzoz
    Contributor

    cc @nodejs/platform-windows

  4. bcoe commented on Feb 22, 2019

    @bcoe
    ContributorAuthor

    I'm seeing another example of this behavior: istanbuljs/istanbuljs#307

  5. mhdawson commented on Feb 22, 2019

    @mhdawson
    Member

    @joaocgreis is this something you can look into?

  6. coreyfarrell commented on Jun 20, 2019

    @coreyfarrell
    Member

    We are now experiencing this issue with node.js 10.16.0 as well, 10.15.0 does not have the issue - https://travis-ci.org/coreyfarrell/nyc/builds/548133760.

    @bcoe Travis-CI documentation says that Windows gets 8GB ram for testing, maybe this is just inadequate for the way they setup Windows (other stuff running)? Can we try a different CI for Windows (appveyor or another)? It does seem like memory requirements for node.js under windows is increasing with each release but maybe this is unavoidable.

  7. added a commit that references this issue on Sep 13, 2019
  8. added
    windowsIssues and PRs related to the Windows platform.
    help wantedIssues that need assistance from volunteers or PRs that need help to proceed.
    on Oct 7, 2019
  9. jasnell commented on Jun 25, 2020

    @jasnell
    Member

    @bcoe ... whatcha think... does this need to remain open?

  10. coreyfarrell commented on Jun 26, 2020

    @coreyfarrell
    Member

    I just retested nyc on Travis for Windows with Node.js 8, 10, 12 and 14. I didn't receive an ENOMEM error this time. Not sure if this means that something was fixed in Node.js or if Travis increased the memory available since the last time I tried.

  11. bcoe commented on Jun 29, 2020

    @bcoe
    ContributorAuthor

    @jasnell @coreyfarrell if we're not seeing this any longer, let's close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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