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: truncate output when maxBuffer is exceeded #24951

Conversation

Fishrock123
Copy link
Contributor

@Fishrock123 Fishrock123 commented Dec 11, 2018

Preserves truncated output for child_process.exec() when maxBuffer is exceeded.

This is particularly useful for commands which have indistinguishable
error codes for what output they produce.


I am presently running into this and just vendoring exec with a similar change into some code because... well, I need it, and don't want to re-write all of exec by hand.

Done as an added option / semver-minor because I want it sooner. IMO we should make this the default behavior but I think there's a chance something relies on the old behavior.
Done as patch as per discussion.

The old behavior was also completely untested so... commit 1 fixes that.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the child_process Issues and PRs related to the child_process subsystem. label Dec 11, 2018
@Fishrock123 Fishrock123 added the semver-minor PRs that contain new features and should be released in the next minor version. label Dec 11, 2018
@BridgeAR
Copy link
Member

@Fishrock123 I would argue this is a kind of bug fix and we do not need the option for it. We could just run CITGM and see if anyone relies on this behavior but I actually doubt that a lot of code relies on the specific error code and that the output is empty in such a case.

@Fishrock123
Copy link
Contributor Author

@nodejs/child_process, and also @nodejs/citgm I suppose. (Since there's no way I can decipher output even if I start a run...)

@BridgeAR
Copy link
Member

I am happy to look into the CITGM result if you refactor the code / open an alternative one which adds the functionality without option.

@Fishrock123 Fishrock123 force-pushed the child-process-exec-truncateMaxBuffer branch from 978d141 to c059ef0 Compare December 12, 2018 18:52
@Fishrock123 Fishrock123 removed the semver-minor PRs that contain new features and should be released in the next minor version. label Dec 12, 2018
@Fishrock123 Fishrock123 force-pushed the child-process-exec-truncateMaxBuffer branch from c059ef0 to dfd1f12 Compare December 12, 2018 19:00
@Fishrock123 Fishrock123 changed the title child_process: add truncateMaxBuffer option to exec() child_process: truncate output when maxBuffer is exceeded Dec 12, 2018
@Fishrock123
Copy link
Contributor Author

Fishrock123 commented Dec 12, 2018

@Fishrock123 Fishrock123 force-pushed the child-process-exec-truncateMaxBuffer branch from dfd1f12 to 31e35bd Compare December 12, 2018 22:18
@addaleax
Copy link
Member

@Trott
Copy link
Member

Trott commented Dec 15, 2018

Fresh CI: https://ci.nodejs.org/job/node-test-pull-request/19566/

Windows test failures look relevant.

Trott
Trott previously requested changes Dec 15, 2018
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking on relevant CI failures on Windows. Feel free to dismiss once those are addressed. I'm just blocking to make sure no one accidentally lands this before it's fixed.

@Fishrock123
Copy link
Contributor Author

Fishrock123 commented Dec 19, 2018

🤨(wat.)

(Why did 4 of the same test case run in fanned?)

anyways:

assert.js:86
  throw new AssertionError(obj);
  ^

AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected

+ '"hell'
- 'hello'
    at runChecks (c:\workspace\node-test-binary-windows\test\parallel\test-child-process-exec-maxBuffer.js:10:10)
    at cp.exec.common.mustCall (c:\workspace\node-test-binary-windows\test\parallel\test-child-process-exec-maxBuffer.js:31:7)
    at c:\workspace\node-test-binary-windows\test\common\index.js:335:15
    at ChildProcess.exithandler (child_process.js:301:5)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:978:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)

So.... on windows (cmd.exe?) echo "x" returns "x" and not x?...

@Fishrock123 Fishrock123 force-pushed the child-process-exec-truncateMaxBuffer branch from 31e35bd to 42db815 Compare December 19, 2018 02:41
@Fishrock123
Copy link
Contributor Author

@Trott
Copy link
Member

Trott commented Dec 19, 2018

Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/19672/ ✔️

@Fishrock123 Fishrock123 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 19, 2018
@Trott Trott dismissed their stale review December 19, 2018 07:21

test no longer fails

@Trott
Copy link
Member

Trott commented Dec 31, 2018

No one has reviewed this since the last commit was pushed. @addaleax @BridgeAR Can you confirm that this still looks good to you? Anyone else want to review it? @nodejs/child_process

@Fishrock123 Are you still in Camp "I Like To Land My Own PRs, Please Don't Land Them For Me, KThxBai"? Or have you moved over to Camp "Sure, Whatevs, Land My PRs If You Want, Save Me The Trouble, Kewl"?

@Fishrock123
Copy link
Contributor Author

I would prefer to land them myself to avoid surprises.

Anyways this should be ready to land? It's not clear to me if people are actually ok with this considering no one from the relevant domain has ever commented.

@Trott
Copy link
Member

Trott commented Jan 4, 2019

Anyways this should be ready to land?

Technically, yes, I believe so.

It's not clear to me if people are actually ok with this considering no one from the relevant domain has ever commented.

If you'd be more comfortable getting the approval of someone specific, please do, obviously. (As you know, GitHub notifications can be overwhelming so it's sometimes a good idea to ping folks via other channels.)

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, still LGTM

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM

@Fishrock123 Fishrock123 force-pushed the child-process-exec-truncateMaxBuffer branch from 42db815 to 3f6aebf Compare January 12, 2019 02:50
@Fishrock123
Copy link
Contributor Author

https://ci.nodejs.org/job/node-test-commit-arm/21379/nodes=ubuntu1604-arm64/testReport/(root)/test/known_issues_test_vm_timeout_escape_queuemicrotask/

test.known_issues/test-vm-timeout-escape-queuemicrotask
fail (0)
(node:54495) ExperimentalWarning: queueMicrotask() is experimental.

@Fishrock123 Fishrock123 deleted the child-process-exec-truncateMaxBuffer branch January 23, 2019 23:47
Fishrock123 added a commit that referenced this pull request Jan 23, 2019
Expands this test case to check what happens to stdout/stderr when
maxBuffer is exceeded.

Also changes how cases are checked so that assertion stacks are
tracable to their test case, aka 'make it actually debuggable'.

PR-URL: #24951
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Fishrock123 added a commit that referenced this pull request Jan 23, 2019
Preserves truncated output for `child_process.exec()` when `maxBuffer`
is exceeded.

This is particularly useful for commands which have indistinguishable
error codes for what output they produce.

PR-URL: #24951
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Trott added a commit to Trott/io.js that referenced this pull request Jan 24, 2019
Fix test/pummel/test-exec.js which broke as a result of
e47f972
(nodejs#24951).

(Until very recently, pummel tests were not run at all in CI and
currently only run nightly on master.)
@Trott Trott mentioned this pull request Jan 24, 2019
2 tasks
targos pushed a commit that referenced this pull request Jan 24, 2019
Expands this test case to check what happens to stdout/stderr when
maxBuffer is exceeded.

Also changes how cases are checked so that assertion stacks are
tracable to their test case, aka 'make it actually debuggable'.

PR-URL: #24951
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
targos pushed a commit that referenced this pull request Jan 24, 2019
Preserves truncated output for `child_process.exec()` when `maxBuffer`
is exceeded.

This is particularly useful for commands which have indistinguishable
error codes for what output they produce.

PR-URL: #24951
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Trott added a commit to Trott/io.js that referenced this pull request Jan 24, 2019
Fix test/pummel/test-exec.js which broke as a result of
e47f972
(nodejs#24951).

(Until very recently, pummel tests were not run at all in CI and
currently only run nightly on master.)

PR-URL: nodejs#25677
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jan 24, 2019
Fix test/pummel/test-exec.js which broke as a result of
e47f972
(#24951).

(Until very recently, pummel tests were not run at all in CI and
currently only run nightly on master.)

PR-URL: #25677
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jan 24, 2019
MylesBorins added a commit that referenced this pull request Jan 24, 2019
Notable Changes:

* events:
  * For unhandled `error` events with an argument that is not an
    `Error` object, the resulting exeption will have more information
    about the argument.
    #25621
* child_process:
  * When the `maxBuffer` option is passed, `stdout` and `stderr` will
    be truncated rather than unavailable in case of an error.
    #24951
* policy:
  * Experimental support for module integrity checks through a manifest
    file is implemented now.
    #23834
* n-api:
  * The `napi_threadsafe_function` feature is now stable.
    #25556
* report:
  * An experimental diagnostic API for capturing process state is
    available as `process.report` and through command line flags.
    #22712
* tls:
  * `tls.connect()` takes a `timeout` option analogous to the
    `net.connect()` one.
    #25517
* worker:
  * `process.umask()` is available as a read-only function inside Worker
    threads now.
    #25526
  * An `execArgv` option that supports a subset of Node.js command line
    options is supported now.
    #25467

PR-URL: #25687
MylesBorins added a commit that referenced this pull request Jan 25, 2019
Notable Changes:

* events:
  * For unhandled `error` events with an argument that is not an
    `Error` object, the resulting exeption will have more information
    about the argument.
    #25621
* child_process:
  * When the `maxBuffer` option is passed, `stdout` and `stderr` will
    be truncated rather than unavailable in case of an error.
    #24951
* policy:
  * Experimental support for module integrity checks through a manifest
    file is implemented now.
    #23834
* n-api:
  * The `napi_threadsafe_function` feature is now stable.
    #25556
* report:
  * An experimental diagnostic API for capturing process state is
    available as `process.report` and through command line flags.
    #22712
* tls:
  * `tls.connect()` takes a `timeout` option analogous to the
    `net.connect()` one.
    #25517
* worker:
  * `process.umask()` is available as a read-only function inside Worker
    threads now.
    #25526
  * An `execArgv` option that supports a subset of Node.js command line
    options is supported now.
    #25467

PR-URL: #25687
BethGriggs pushed a commit that referenced this pull request Apr 29, 2019
Expands this test case to check what happens to stdout/stderr when
maxBuffer is exceeded.

Also changes how cases are checked so that assertion stacks are
tracable to their test case, aka 'make it actually debuggable'.

PR-URL: #24951
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
BethGriggs pushed a commit that referenced this pull request Apr 29, 2019
Preserves truncated output for `child_process.exec()` when `maxBuffer`
is exceeded.

This is particularly useful for commands which have indistinguishable
error codes for what output they produce.

PR-URL: #24951
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
BethGriggs pushed a commit that referenced this pull request Apr 29, 2019
Fix test/pummel/test-exec.js which broke as a result of
e47f972
(#24951).

(Until very recently, pummel tests were not run at all in CI and
currently only run nightly on master.)

PR-URL: #25677
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
@BethGriggs BethGriggs mentioned this pull request May 1, 2019
BethGriggs pushed a commit that referenced this pull request May 10, 2019
Expands this test case to check what happens to stdout/stderr when
maxBuffer is exceeded.

Also changes how cases are checked so that assertion stacks are
tracable to their test case, aka 'make it actually debuggable'.

PR-URL: #24951
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
BethGriggs pushed a commit that referenced this pull request May 10, 2019
Preserves truncated output for `child_process.exec()` when `maxBuffer`
is exceeded.

This is particularly useful for commands which have indistinguishable
error codes for what output they produce.

PR-URL: #24951
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
BethGriggs pushed a commit that referenced this pull request May 10, 2019
Fix test/pummel/test-exec.js which broke as a result of
e47f972
(#24951).

(Until very recently, pummel tests were not run at all in CI and
currently only run nightly on master.)

PR-URL: #25677
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
MylesBorins pushed a commit that referenced this pull request May 16, 2019
Expands this test case to check what happens to stdout/stderr when
maxBuffer is exceeded.

Also changes how cases are checked so that assertion stacks are
tracable to their test case, aka 'make it actually debuggable'.

PR-URL: #24951
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request May 16, 2019
Preserves truncated output for `child_process.exec()` when `maxBuffer`
is exceeded.

This is particularly useful for commands which have indistinguishable
error codes for what output they produce.

PR-URL: #24951
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request May 16, 2019
Fix test/pummel/test-exec.js which broke as a result of
e47f972
(#24951).

(Until very recently, pummel tests were not run at all in CI and
currently only run nightly on master.)

PR-URL: #25677
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. child_process Issues and PRs related to the child_process subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants