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: closes before flushing all data #4074

Closed
oldrich-s opened this issue Nov 30, 2015 · 8 comments
Closed

child_process: closes before flushing all data #4074

oldrich-s opened this issue Nov 30, 2015 · 8 comments
Labels
child_process Issues and PRs related to the child_process subsystem.

Comments

@oldrich-s
Copy link

I use NodeJS v5.1.0 x64 on Windows 10. The following code

var cp = require('child_process');

var stdout = "";
var stderr = "";

var process = cp.spawn("git", ["ls-remote", "--tags", "--heads", "git://github.com/jquery/jquery.git"]);

process.stdout.on('data', function (data) {
    var text = data.toString();
    stdout += text;
});

process.stderr.on('data', function (data) {
    var text = data.toString();
    stderr += text;
});

process.on('error', function (error) {
    debugger;
});

process.on('close', function (code) {
    debugger;
});

process.on('exit', function (code) {
    debugger;
});

results in the following text in stdout and then the exit and close events are triggered. You can see that the response is incomplete. When I call the command in the Windows CMD directly, I get a complete response back.

ff619f3b978304700add92952485a5fb0a8fd80c    refs/heads/1.12-stable
4fea389ad2b7515bc3a9081245979ab7be566b99    refs/heads/2.2-stable
83391859bda90f630bf02a5e04d82e9f1babeb1f    refs/heads/compat
90347a78d69b15a515c462eb378adb7e6067f5dd    refs/heads/killphp
eaa3e9f0cfc68083556cf61195821d90e369f646    refs/heads/master
bcc8a837055fe720579628d758b7034d6b520f2e    refs/tags/1.0
bcc8a837055fe720579628d758b7034d6b520f2e    refs/tags/1.0.1
dbee06de85859af59591813d3004e6695b8bb278    refs/tags/1.0.2
4e3da33c59fafe34e237585743e86e24ba81046e    refs/tags/1.0.3
ed37ca66e5f79b4250f38cbd7a7f809ebfc15a20    refs/tags/1.0.4
73f55becc5e056ad28f6aec22ec014ffb3ab913b    refs/tags/1.0a
2aa67026ebe6bea90fd137fc99b4c9422977e3f0    refs/tags/1.1
2550b1ea6a6eb6ba50d378a5dcfbc8146ca88bff    refs/tags/1.1.1
92973279ea26c415f505d187276460115c668f17    refs/tags/1.1.2
fdd437800d983346c5936abedcf292c2a612b892    refs/tags/1.1.3
f70010b0ad13e3e4d6366287fd79636a9ceca1cd    refs/tags/1.1.3.1
19f5cf0c893aa2ba2ffb00c00c7efc1db4383f3e    refs/tags/1.1.3a
557ec9a92f40f97254e48240825fcb9be5a08e20    refs/tags/1.1.4
2c62b787b2cafb32af14edadc963b8ba3cb847b8    refs/tags/1.10.0
3a8fcde250da0db237396e9ab97fb099eb68c624    refs/tags/1.10.0-beta1
935eb19d87063ec30b717b3d45368d3c73cb591d    refs/tags/1.10.1
16b079b164d62bd807c612806842a13bf9b04d17    refs/tags/1.10.2
91cd1587ed4a1d4f3834227e8eb3cc30cb385409    refs/tags/1.11.0
b44595824c3f23441eab2f34551587c5ae6fd31c    refs/tags/1.11.0-beta1
02cb5be0bb5a49cda3a187d169d89d91874bbf1e    refs/tags/1.11.0-beta2
5bb568cd61cb127ef4ebcc63bb48a37cd5af562d    refs/tags/1.11.0-beta3
5c62f3cd019218e1b401ce2cf4cad644772e387f    refs/tags/1.11.0-rc1
0d5ec2d8ac94a419ee47a39319c43ff9a7326b50    refs/tags/1.11.1
b6c4e50fb8f24dcf7bf38e053e68c4d0e7f059e8    refs/tags/1.11.1-beta1
baa21ff7a91ca165b63a5f900313da14c36fe255    refs/tags/1.11.1-rc1
b50c9a8d92f94f310138f4528e3a36b5336539a1    refs/tags/1.11.1-rc2
9690801db01709bfbff5f977d07fb7cc14472908    refs/tags/1.11.2
1472290917f17af05e98007136096784f9051fab    refs/tags/1.11.3
8bcb016dfaa029a5e98cc3c25b9f999053217f36    refs/tags/1.1a
d1390665b6e7d475d237cafcf8948440c9adfbf8    refs/tags/1.1b
ce256312d518e16a6ee7df5f7f301b8bf9a1caf2    refs/tags/1.2
456da2d4a805012003df3c1b173148368d3536f7    refs/tags/1.2.1
6c81082a6b20880cbd5d35ec5c50d4270f3af2ce    refs/tags/1.2.2
13a5fdb6a1571012c3e065a991fb4eff083057fb    refs/tags/1.2.2b
3f839a69c5682419c921a1a2110289c8941556b0    refs/tags/1.2.2b2
d9a3c4fefaf84db7eba9b1f8204d1e134266b823    refs/tags/1.2.3
32ba00081ddd56c00655d0a7b7825ac947247cc6    refs/tags/1.2.3a
2c07690377522119891784ec11c89e87f0a12545    refs/tags/1.2.3b
2db27efd662693dd90fbf89ea1e4bbee7c9fb929    refs/tags/1.2.4
1ba2865b089fc06242004b7003b4f8dcfd92dc13    refs/tags/1.2.4a
44a6f5d0cb7f1124cd80e9b72d1fff9a46fe4c0b    refs/tags/1.2.4b
456d8a62ccf3244c58ace2b315694ad54cfc05e3    refs/tags/1.2.5
ee931edfea95a0ed49aa4382b5c09cae6f7dafdb    refs/tags/1.2.6
9dc7a3a7d20c0e75b927c956cba8de4dc30db077    refs/tags/1.3
9dc7a3a7d20c0e75b927c956cba8de4dc30db077    refs/tags/1.3.0
6df57d1b82c88ea85d2be081ee8f2362e1c362b7    refs/tags/1.3.1
8b79ea13656727e2449807a812dd0fd8c2783aad    refs/tags/1.3.1rc1
13e9cde0efeadbbc5b3a375ee642bed394dd3a59    refs/tags/1.3.2
df1f656aae019bab1c0e84b41aca26714b4d0d5c    refs/tags/1.3b1
c786f1097ee26095f2f7eb721a450c550775ba84    refs/tags/1.3b2
869afc46cd8229f41d82380f01830dd59a0084f7    refs/tags/1.3rc1
4ce38155a8978c053f0b5938ef3e3f8729381e38    refs/tags/1.4
4ce38155a8978c053f0b5938ef3e3f8729381e38    refs/tags/1.4.0
15d261b9673e153f9e9710da897de62c306afe53    refs/tags/1.4.1
9e4beb5ac258bfc834913c1781891ef49b2deb93    refs/tags/1.4.2
07458abcaf02b5e991223953081bb0dd5240e2c1    refs/tags/1.4.3
66a788ab837fd9b483740ee0b44c1e76f846aadd    refs/tags/1.4.3rc1
3e5520fbdc7231b3f38e145020b40524c1e6654d    refs/tags/1.4.3rc2
9b20df0375f37cc0997bd8ed3d1892a23967d3d5    refs/tags/1.4.4
c22623602ee3c9ff70df9e6f51132931d19bab04    refs/tags/1.4.4rc1
4d7f7453dca8e385cfb02089a8d5b2c47371bba3    refs/tags/1.4.4rc2
50708c070704c607a0ddc51679b93845c8fee5e1    refs/tags/1.4.4rc3
c90a1cb61b41a5686bc3764f144a156e734ed459    refs/tags/1.4a1
f745357baec82e0be59c651f70d1e489f237c398    refs/tags/1.4a2
857d8afd6917775b7cef6fd22e57dd9acec77f01    refs/tags/1.4rc1
675226eea749

EDIT:

The same happens on NodeJS v4.2.2 x86

@evanlucas
Copy link
Contributor

hm, I'm wondering if this is Windows specific. I cannot reproduce on OS X

/cc @nodejs/platform-windows

@oldrich-s
Copy link
Author

I think that it is my pc specific. I have just installed Git and NodeJS on my wife's pc with Windows 10 and it worked. Any recommendation what to do to make it work? I have tried to reinstall NodeJS and Git but nothing helped.

In the worst case I will have to reinstall whole pc.

@ChALkeR ChALkeR added the child_process Issues and PRs related to the child_process subsystem. label Nov 30, 2015
@mscdex
Copy link
Contributor

mscdex commented Nov 30, 2015

If you're looking at the output as of the exit event, you could easily not have all of the output yet. Are you saying it is still incomplete on the close event, which is actually when the stdio streams have finished?

@cjihrig
Copy link
Contributor

cjihrig commented Nov 30, 2015

Any chance that applying the change in #4071 solves your problem?

@oldrich-s
Copy link
Author

@mscdex yes the problem exists also with close event. I have found the problem by using bower that uses git commands. see here

@cjihrig How can I test it? Do I need to compile Node.JS on my own?

@cjihrig
Copy link
Contributor

cjihrig commented Nov 30, 2015

Yes. You would have to build from source.

@cjihrig
Copy link
Contributor

cjihrig commented Feb 16, 2016

@czb is this still an issue for you? If so, can you test with Node v4.2.5+ or v5.2.0+?

@cjihrig
Copy link
Contributor

cjihrig commented May 17, 2017

No follow up. Closing.

@cjihrig cjihrig closed this as completed May 17, 2017
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

No branches or pull requests

5 participants