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

Errors downstream of .write() are being squelched #98

Closed
KodeAndGame opened this issue Sep 27, 2015 · 4 comments
Closed

Errors downstream of .write() are being squelched #98

KodeAndGame opened this issue Sep 27, 2015 · 4 comments

Comments

@KodeAndGame
Copy link
Contributor

I had an error in a Transformer stream that was being piped to from the readable stream generated by .write(). However, it took me some time to figure out where the error was because the process was being exited cleanly and trying to use process.on to catch uncaught exceptions wasn't fixing that. Eventually, I came to realize the error was being squelched by something in xray or one of it's dependencies (e.g. maybe batch). Feel free to let me know if I'm completely off base here.

I've created a gist that shows two examples. App.js starts with xray.write, pipes it to my transform which throws an error and then pipes that to stdout. Process exits and no errors are reported to console. Conversely, alt.js starts with stdin, pipes it to the same transform and then to stdout. Process exits with the exception I threw.

I did my best to look through lib/walk and batch/index which seem to be the two files where my error gets moved around between callbacks but unfortunately I didn't really get anywhere. I'd be willing to try fixing this in a PR myself if I could be pointed in the right direction but I'm kind of at a loss here.

Any help is appreciated. Thanks!

@KodeAndGame
Copy link
Contributor Author

This might the be the same as #87. It's not exactly clear.

@KodeAndGame
Copy link
Contributor Author

I had better luck debugging and have updated my gist with a log of my session. Long story short, my error gets passed around a couple times between lib/walk and batch. Presumably this is in order to complete the batch but I still haven't dug in enough to know for sure.

Finally when batch is done, it doesn't check to see if there's an error, it just exits the function, doing nothing with the error that's been passed around. You can see this in batch/index.js:124.

My instinct is to stop it somewhere in lib/walk or at least provide a caller (i.e. me) the option to do so but I'm not sure if this is a breaking change for other users of your package. I'm going to do a little more digging and see if I can get a PR in.

KodeAndGame added a commit to KodeAndGame/x-ray that referenced this issue Sep 29, 2015
This change fixes one of the issues from matthewmueller#98. `state.stream` can be the wrong stream to emit an error to if no path is passed however `ret` will always be the right stream to emit to. 

This makes it possible to listen for 'error' events although an error is still squelched if it's not listened for.
@jonknapp
Copy link

Would we be able to get a new version of the library this with fix pulled in? Not sure of the state of the other commits since the last release or I'd make the branch myself.

@senf666
Copy link
Collaborator

senf666 commented Jul 6, 2017

2.10 25 Mar 2016 contains this, closing.

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

No branches or pull requests

3 participants