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: Allow an unlimited maxBuffer size in child_process #10767

Closed
wants to merge 1 commit into from

Conversation

jwdeitch
Copy link

Allow unlimited buffer for child_process'

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

child_process

@nodejs-github-bot nodejs-github-bot added the child_process Issues and PRs related to the child_process subsystem. label Jan 12, 2017
@mscdex
Copy link
Contributor

mscdex commented Jan 12, 2017

This isn't necessary, just pass Infinity as your maxBuffer value.

@cjihrig
Copy link
Contributor

cjihrig commented Jan 12, 2017

Yes, what @mscdex said. Also, this patch doesn't address stderr.

@addaleax
Copy link
Member

Fwiw, passing Infinity seems to give an TypeError: "maxBuffer" must be an unsigned integer error?

@cjihrig
Copy link
Contributor

cjihrig commented Jan 12, 2017

That should only happen for spawnSync(). execFile() should handle it fine.

@addaleax
Copy link
Member

execFile() should handle it fine.

I tested this as:

> child_process.execSync('cat /dev/urandom', {maxBuffer:Infinity})
TypeError: "maxBuffer" must be an unsigned integer

@cjihrig
Copy link
Contributor

cjihrig commented Jan 12, 2017

Yea, execSync() uses spawnSync() under the hood. execFile() should work though. I'm looking into making spawnSync() support Infinity right now.

@sam-github
Copy link
Contributor

sam-github commented Jan 12, 2017

I think allowing Infinity would be better than 0 to mean unlimited.

That Infinity is valid isn't documented anywhere, and apparently, its support is random: yes for execFile, no for spawnSync, and for execFileSync, who knows? Is that accidental, or intentional?

And

> child_process.execSync('date', {maxBuffer: Infinity}, ()=>{})
node: ../deps/uv/src/unix/core.c:166: uv_close: Assertion `0' failed.
zsh: abort (core dumped)  node
core/node (master $% u=) % node --version 
v7.2.0

Hm. EDIT: #10768

execFileSync also doesn't document a default for maxBuffer, its not clear if its defaulting to no limit, or to something else.

@mscdex
Copy link
Contributor

mscdex commented Jan 12, 2017

I don't know why the sync counterparts perform different argument checking. I'd personally prefer simpler validation, that the value is just a number (typeof maxBuffer === 'number') rather than strictly Number.isInteger(maxBuffer).

@sam-github
Copy link
Contributor

Btw, rebuilding to see if the abort is reproduceable.

@cjihrig
Copy link
Contributor

cjihrig commented Jan 12, 2017

The sync calls don't currently support it because it is CHECK()'ed as a uint in C++.

@cjihrig
Copy link
Contributor

cjihrig commented Jan 12, 2017

#10769

@jwdeitch jwdeitch closed this Jan 12, 2017
cjihrig added a commit to cjihrig/node that referenced this pull request Jan 17, 2017
Fixes: nodejs#10767
PR-URL: nodejs#10769
Reviewed-By: James M Snell <jasnell@gmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 18, 2017
Fixes: nodejs#10767
PR-URL: nodejs#10769
Reviewed-By: James M Snell <jasnell@gmail.com>
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants