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

CLI tool exits immediately instead of reading from STDIN on Cygwin #121

Closed
yelworc opened this issue Jan 22, 2014 · 2 comments
Closed

CLI tool exits immediately instead of reading from STDIN on Cygwin #121

yelworc opened this issue Jan 22, 2014 · 2 comments

Comments

@yelworc
Copy link

yelworc commented Jan 22, 2014

Apologies in advance if this turns out to be a Cygwin issue, rather than a Bunyan bug.

Running the following simple test program:

var log = require('bunyan').createLogger({name: 'test'});
setTimeout(function() { log.info('boofar'); }, 1000);

Results in this output when run in the Cygwin terminal, and trying to have the bunyan CLI tool format the output:

$ node test.js | bunyan  
* * *

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: write EPIPE
    at errnoException (net.js:901:11)
    at Socket._write (net.js:643:26)
    at doWrite (_stream_writable.js:221:10)
    at writeOrBuffer (_stream_writable.js:211:5)
    at Socket.Writable.write (_stream_writable.js:180:11)
    at Socket.write (net.js:613:40)
    at Logger._emit (T:\eleven\eleven-throwaway-server\node_modules\bunyan\lib\bunyan.js:742:22)
    at Logger.info (T:\eleven\eleven-throwaway-server\node_modules\bunyan\lib\bunyan.js:819:24)
    at null._onTimeout (T:\eleven\eleven-throwaway-server\test.js:2:29)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

It seems like the bunyan process exits immediately (after printing the * * *), so the log statement fails to write to STDOUT.
FWIW, the same example works just fine in the standard Windows shell on the same machine. Piping the output into something else (like less) works fine, too.

@yelworc
Copy link
Author

yelworc commented Feb 4, 2014

Hmm... When I comment out the uncaughtException handler in bunyan, it prints this:

Error: EINVAL, invalid argument
    at new Socket (net.js:157:18)
    at process.stdin (node.js:660:19)
    at processStdin ([...]\npm\node_modules\bunyan\bin\bunyan:997:24)
    at main ([...]\npm\node_modules\bunyan\bin\bunyan:1496:9)
    at Object.<anonymous> ([...]\npm\node_modules\bunyan\bin\bunyan:1515:5)
    [...]

Googling that leads to nodejs/node-v0.x-archive#6459, so this problem seems to be way outside the scope of Bunyan. Feel free to close the issue; I would be happy if there was some sort of workaround, though.

@trentm
Copy link
Owner

trentm commented May 3, 2017

Happy to accept a work around PR that doesn't loose the uncaughtException handler facility for other platforms. However, given that this is a node core issue (not supporting cygwin), I'm closing this for now.

Sorry I don't have a better answer.

@trentm trentm closed this as completed May 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants