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

STDIN mode can't terminate? #100

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

STDIN mode can't terminate? #100

tiliv opened this issue Aug 14, 2013 · 9 comments
Labels
npm

Comments

@tiliv
Copy link

@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
Copy link
Contributor

@tml 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
Copy link
Author

@tiliv 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
Copy link
Author

@tiliv 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
Copy link
Contributor

@tml 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
Copy link
Contributor

@tml 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
Copy link

@jhthorsen jhthorsen commented 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.

@tml
Copy link
Contributor

@tml 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
Copy link
Contributor

@brad 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
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
Copy link
Contributor

@tml 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.