plasma-umass / doppio

Breaks the browser language barrier (includes a plugin-free JVM).
http://plasma-umass.github.io/doppio-demo
MIT License
2.16k stars 175 forks source link

stdout events don't work #400

Closed hrj closed 8 years ago

hrj commented 8 years ago

I want to print the output from System.out.println into the browser console. Based on the code given in the wiki page, I tried something like this:

BrowserFS.install(window);
window.process.stdout.on('data', function(data) {
   console.log("Received the following output: ", data.toString());
 });

But the handler doesn't ever get called. I also tried registering on the ready event:

window.process.stdout.on('ready', function() {
   console.log("Received the following output: ", window.process.stdout.read());
 });

The ready event doesn't fire either.

The data does get accumulated in the stream however. If I call this in the browser console:

process.stdout.read().toString();

... I can see the data in there.

I have tried this with very old doppio, current npm release, as well as latest master. Any ideas?

Thanks!

jvilk commented 8 years ago

You're right. This is a bug in bfs-process, where I implement the _read function incorrectly. I noticed shortly after you posted an issue there, but haven't had time to fix yet. I plan to fix this before releasing a new version of doppio.

jvilk commented 8 years ago

As an aside, I have unit tests for this, but they don't test whether or not they never run, so they have been trivially passing for awhile now. Doh!

jimfb commented 8 years ago

@jvilk Any update on this one?

jvilk commented 8 years ago

Almost finished a fix before the holidays. Will poke at it further this week. Node streams have a weird interface, and I had some subtle issues with unit testing them.

jvilk commented 8 years ago

Just fixed this in the latest BrowserFS, which Doppio now depends on. Let me know if you continue to have issues.

hrj commented 8 years ago

Confirmed that this works now. Thanks! However,

jvilk commented 8 years ago

I just addressed your second bullet in another BFS release. There's a circular dependency that I had to work around in bfs-process that BrowserFS now fixes.

I'll look into the ready event.

jvilk commented 8 years ago

Actually, is the ready event documented? What's the semantics?

hrj commented 8 years ago

Actually, is the ready event documented? What's the semantics?

Ooops, my bad. I wanted to listen to the readable event as documented here but I tried ready by mistake.

Looking again at the documentation, I see no advantage in using readable over data.. It is just one of the things I was trying some weeks back to get stdout to work. So it is not a blocker for me.

I just addressed your second bullet in another BFS release. There's a circular dependency that I had to work around in bfs-process that BrowserFS now fixes.

Cool, thanks! I will try that and report if it doesn't work.