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

stdout of spawned child process is truncated or gone. Extension doesn't get the output of the command. #46002

Closed
juanfe-google opened this issue Mar 16, 2018 · 9 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@juanfe-google
Copy link

  • VSCode Version:
    Version 1.21.1 (1.21.1)
  • OS Version:
    OSX 10.13.3 (17D102)

The root of the issue is in nodeJS: nodejs/node#6379

Steps to Reproduce:

  1. Use child_process.spawn, or any other child process function in nodejs.
  2. See the output of stdout in the extension.

Example:
const proc = require('child_process').spawnSync('git', ['status']); console.log(String(proc.stdout));

@isidorn isidorn removed their assignment Mar 19, 2018
@sandy081 sandy081 removed their assignment Mar 19, 2018
@kenny-y
Copy link

kenny-y commented Mar 26, 2018

Not sure this is gonna help or not: AFAIK, console.log() won't be able to write too much data in a short amount of time, and it's async (on pipes). Use process.stdout.write() and when it returns false, you'll have to wait on drain event before you can write more data.

@alexdima
Copy link
Member

@juanfe-google

We are using spawn and exec in our own built-in git extension like here or here and AFAIK that works fine for us.

So perhaps it is a problem with spawnSync ? (which is a horrible variant to use, as it blocks the entire EH process)

@alexdima alexdima added the info-needed Issue requires more information from poster label Mar 28, 2018
@juanfe-google
Copy link
Author

@alexandrudima In the tool I'm working on uses spawn instead of spawnSync (which was chosen to simplify the example).

The issue is specific to nodeJS running on OSX. nodejs/node#2360

@alexdima
Copy link
Member

alexdima commented Apr 5, 2018

ping @joaomoreno

Is there some magic sauce you're using when spawning git such that you always get the entire output?

@alexdima alexdima assigned joaomoreno and alexdima and unassigned alexdima Apr 5, 2018
@joaomoreno
Copy link
Member

No, not really... Just regular old spawn.

@alexdima
Copy link
Member

alexdima commented Apr 5, 2018

@juanfe-google I cannot reproduce the problem you are describing. I'm using an extension with the following contents:

  • package.json
{
    "publisher": "alex",
    "name": "46002",
    "version": "0.0.0",
    "engines": {
        "vscode": "^1.0.0"
    },
    "activationEvents": [
        "*"
    ],
    "main": "index.js"
}
  • index.js
const cp = require('child_process');
const vscode = require('vscode');

const proc = cp.spawnSync('git', ['status'], {
    cwd: vscode.workspace.rootPath
});
console.log(String(proc.stdout));

And I see the entire output of git status in the VS Code Developer Tools Console.

@juanfe-google
Copy link
Author

@alexandrudima what Mac OS X version are you running?

@alexdima
Copy link
Member

alexdima commented Apr 6, 2018

I am using macOS High Sierra, Version 10.13.4. Would this be something that reproduces only on certain macOS versions?

@vscodebot vscodebot bot closed this as completed Apr 13, 2018
@vscodebot
Copy link

vscodebot bot commented Apr 13, 2018

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot locked and limited conversation to collaborators May 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

6 participants