STDIN mode can't terminate? #100

Closed
tiliv opened this Issue Aug 14, 2013 · 9 comments

Comments

Projects
None yet
4 participants
@tiliv

tiliv commented Aug 14, 2013

I noticed some applications were hanging when relying on yuicompressor to finish executing on stdin input.

After tinkering, I discovered that I can't actually end the stdin from a terminal either:

$ yuicompressor --type css
.blahblah {
    display: block;
}
^D

I push Ctrl-D to signal EOF and nothing happens. I push enter a few times, input Ctrl-D a few more times. Nothing.

This stands in contrast to using other utilities such as ugilfyjs, or any host of other unix command line tools (e.g., cat).

Any ideas? What special treatment do I need to give the input stream to let yuicompressor return properly?

@tml

This comment has been minimized.

Show comment
Hide comment
@tml

tml Aug 15, 2013

Contributor

I am unable to reproduce this one - sending an EOF with ^D works just fine for me on Linux and Mac OS X. What is your "yuicompressor" command here? I assume you have some shell script wrapping things?

http://showterm.io/6b85ccf9f09a2b159fee4 (you can't see me hitting ^D, but I promise, that's what I'm doing here)

Contributor

tml commented Aug 15, 2013

I am unable to reproduce this one - sending an EOF with ^D works just fine for me on Linux and Mac OS X. What is your "yuicompressor" command here? I assume you have some shell script wrapping things?

http://showterm.io/6b85ccf9f09a2b159fee4 (you can't see me hitting ^D, but I promise, that's what I'm doing here)

@ghost ghost assigned tml Aug 15, 2013

@tiliv

This comment has been minimized.

Show comment
Hide comment
@tiliv

tiliv Aug 15, 2013

Very interesting!

So it appears that running the jar directly as you indicated works as expected. The problem seems isolated right now to the node.js script. In this instance, I'm using homebrew to install npm, and then I've used that npm to install the yuicompressor package. From there, I get an executable yuicompressor to run from the command line, as is expected for packages like this. (I referenced uglifyjs earlier, for example.)

You can see my try to use first the jar and then the npm script: http://showterm.io/00a959c8fad20d46edb93

I'm not really familiar with how to do packaging for node.js, so I don't know how to recognize what layer of the setup is to blame.

tiliv commented Aug 15, 2013

Very interesting!

So it appears that running the jar directly as you indicated works as expected. The problem seems isolated right now to the node.js script. In this instance, I'm using homebrew to install npm, and then I've used that npm to install the yuicompressor package. From there, I get an executable yuicompressor to run from the command line, as is expected for packages like this. (I referenced uglifyjs earlier, for example.)

You can see my try to use first the jar and then the npm script: http://showterm.io/00a959c8fad20d46edb93

I'm not really familiar with how to do packaging for node.js, so I don't know how to recognize what layer of the setup is to blame.

@tiliv

This comment has been minimized.

Show comment
Hide comment
@tiliv

tiliv Aug 15, 2013

Sanity test had to be made; my yuicompressor is indeed a symlink to the npm package:

$ ll `which yuicompressor`
/usr/local/bin/yuicompressor@ -> ../lib/node_modules/yuicompressor/nodejs/cli.js

And npm appears to copy files for cli packages from my global ~/.npm/ directory to /usr/local/lib/node_modules/, which is where that symlink is pointing. My showterm had me targetting a jar in the packages installed at my home folder, but they are the same.

Not sure that this changes anything, but I thought it was worth clarifying the situation.

tiliv commented Aug 15, 2013

Sanity test had to be made; my yuicompressor is indeed a symlink to the npm package:

$ ll `which yuicompressor`
/usr/local/bin/yuicompressor@ -> ../lib/node_modules/yuicompressor/nodejs/cli.js

And npm appears to copy files for cli packages from my global ~/.npm/ directory to /usr/local/lib/node_modules/, which is where that symlink is pointing. My showterm had me targetting a jar in the packages installed at my home folder, but they are the same.

Not sure that this changes anything, but I thought it was worth clarifying the situation.

@tml

This comment has been minimized.

Show comment
Hide comment
@tml

tml Aug 15, 2013

Contributor

I'll see if I can figure out what uglifyjs is doing there which we're not. Thanks for the report!

Contributor

tml commented Aug 15, 2013

I'll see if I can figure out what uglifyjs is doing there which we're not. Thanks for the report!

@tml

This comment has been minimized.

Show comment
Hide comment
@tml

tml Aug 15, 2013

Contributor

Seems to be a virtue of using the 'process' module in nodejs; I hopefully be able to push something shortly.

Contributor

tml commented Aug 15, 2013

Seems to be a virtue of using the 'process' module in nodejs; I hopefully be able to push something shortly.

@jhthorsen

This comment has been minimized.

Show comment
Hide comment
@jhthorsen

jhthorsen Sep 15, 2013

This seems to work:

#!/usr/bin/env node
var kexec = require('kexec'),
    fs = require('fs'),
    compressor = require('./index'),
    args = process.argv.slice(2);
args.unshift(compressor.jar);
args.unshift('-jar');
args.unshift('java');
kexec(args.join(' '));

The problem is that there does not seem to be anything "tunneling" STDIN from the node process to the child_process.

This seems to work:

#!/usr/bin/env node
var kexec = require('kexec'),
    fs = require('fs'),
    compressor = require('./index'),
    args = process.argv.slice(2);
args.unshift(compressor.jar);
args.unshift('-jar');
args.unshift('java');
kexec(args.join(' '));

The problem is that there does not seem to be anything "tunneling" STDIN from the node process to the child_process.

@tml

This comment has been minimized.

Show comment
Hide comment
@tml

tml Sep 15, 2013

Contributor

@tiliv Can you try @jhthorsen's suggestion and let me know if it works for you as well? If so, we'll go ahead and move forward with that one.

Contributor

tml commented Sep 15, 2013

@tiliv Can you try @jhthorsen's suggestion and let me know if it works for you as well? If so, we'll go ahead and move forward with that one.

@brad

This comment has been minimized.

Show comment
Hide comment
@brad

brad Jun 11, 2014

Contributor

This is an old bug, but it still seems to be an issue. I'm experiencing this problem with yuicompressor version 2.4.8 on CentOS 6.5. After installing kexec and making the changes suggested by @jhthorsen it seems to be working great! cc @tml

Contributor

brad commented Jun 11, 2014

This is an old bug, but it still seems to be an issue. I'm experiencing this problem with yuicompressor version 2.4.8 on CentOS 6.5. After installing kexec and making the changes suggested by @jhthorsen it seems to be working great! cc @tml

brad added a commit to brad/yuicompressor that referenced this issue Jun 20, 2014

brad added a commit to brad/yuicompressor that referenced this issue Jun 20, 2014

tml added a commit that referenced this issue Jun 30, 2014

Merge pull request #149 from brad/fixhang
fix occasional stdin non-termination, #100

I don't use node/npm, so I have to take the user's word for it on this one. :)
@tml

This comment has been minimized.

Show comment
Hide comment
@tml

tml Jun 30, 2014

Contributor

Closed by #149

Contributor

tml commented Jun 30, 2014

Closed by #149

@tml tml closed this Jun 30, 2014

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