Skip to content

child_process: empty options.env results in ENOMEM error #29008

Description

@ilikesleeping
  • Version: v10.16.1
  • Platform: Windows 10 x64 Version 1803 (OS Build 17134.885)
  • Subsystem: child_process

When calling another process, the exec and execSync commands fail with a ENOMEM error when using an empty object for the options.env variable. Using any non-undefined value at all in the env object makes the call work again.

const { execSync } = require('child_process');
execSync('node', {env: {}}) // Fails with ENOMEM error
execSync('node', {env: {x: undefined}}) // Fails with ENOMEM error
execSync('node', {env: {x: 0}}) // Works

The error trace:

Thrown:
{ Error: spawnSync C:\WINDOWS\system32\cmd.exe ENOMEM
    at Object.spawnSync (internal/child_process.js:1002:20)
    at spawnSync (child_process.js:614:24)
    at execSync (child_process.js:661:13)
  errno: 'ENOMEM',
  code: 'ENOMEM',
  syscall: 'spawnSync C:\\WINDOWS\\system32\\cmd.exe',
  path: 'C:\\WINDOWS\\system32\\cmd.exe',
  spawnargs: [ '/d', '/s', '/c', '"node"' ],
  error: [Circular],
  status: null,
  signal: null,
  output: null,
  pid: 0,
  stdout: null,
  stderr: null }

This did not happen in v10.15.*, and seems to affect v10.16.0 as well.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.libuvIssues and PRs related to the libuv dependency or the uv binding.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