Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

child_process: child_process.spawn ENOMEM on Windows #25484

Closed
bcoe opened this issue Jan 14, 2019 · 8 comments
Closed

child_process: child_process.spawn ENOMEM on Windows #25484

bcoe opened this issue Jan 14, 2019 · 8 comments
Assignees
Labels
child_process Issues and PRs related to the child_process subsystem. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. windows Issues and PRs related to the Windows platform.

Comments

@bcoe
Copy link
Contributor

bcoe commented Jan 14, 2019

  • 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

@bcoe bcoe added the child_process Issues and PRs related to the child_process subsystem. label Jan 14, 2019
@bcoe
Copy link
Contributor Author

bcoe commented Jan 14, 2019

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

@bzoz
Copy link
Contributor

bzoz commented Jan 17, 2019

cc @nodejs/platform-windows

@bcoe
Copy link
Contributor Author

bcoe commented Feb 22, 2019

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

@mhdawson
Copy link
Member

@joaocgreis is this something you can look into?

@coreyfarrell
Copy link
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.

t4n6a1ka added a commit to t4n6a1ka/hub that referenced this issue Sep 13, 2019
name: Main workflow
on: [push]
jobs:
  Ubuntu:
    name: Run Ubuntu
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@master

    - name: Set Node.js 10.x
      uses: actions/setup-node@master
      with:
        version: 10.x

    - name: npm install
      run: npm install

    - name: Bootstrap
      run: npm run bootstrap

    - name: Compile
      run: npm run build

    - name: npm test
      run: npm test

    - name: Lint
      run: npm run lint

    - name: Format
      run: npm run format-check
  macOS:
    name: Run macOS
    runs-on: macos-latest
    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Set Node.js 10.x
        uses: actions/setup-node@master
        with:
          version: 10.x

      - name: npm install
        run: npm install

      - name: Bootstrap
        run: npm run bootstrap

      - name: Compile
        run: npm run build

      - name: npm test
        run: npm test
  Windows:
    name: Run Windows
    runs-on: windows-latest
    steps:
    - name: Checkout
      uses: actions/checkout@master

    - name: Set Node.js 10.x
      uses: actions/setup-node@master
      with:
        version: 10.x

    - name: npm install
      run: npm install

    - name: Bootstrap
      run: npm run bootstrap

    - name: Compile
      run: npm run build

    # TODO: This currently ignores exec due to issues with Node and spawning on Windows, which I think is exacerbated by Jest.
    # It doesn't seem to affect behavior in actions themselves, just when testing with Jest.
    # See other similar issues here: nodejs/node#25484
    - name: npm test
      run: npm run test-ci
@bcoe bcoe added windows Issues and PRs related to the Windows platform. Hacktoberfest help wanted Issues that need assistance from volunteers or PRs that need help to proceed. labels Oct 7, 2019
@jasnell
Copy link
Member

jasnell commented Jun 25, 2020

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

@coreyfarrell
Copy link
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.

@bcoe
Copy link
Contributor Author

bcoe commented Jun 29, 2020

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

@bcoe bcoe closed this as completed Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

8 participants