System.stdout.flush () does not work in phantomjs

I am trying to create a phantomjs script that reads "commands" from standard input and writes the result to the standard output of INTERACTIVELY. This script is then executed on phantom through a .NET process that will write and read from threads. I'm having trouble getting phantom output on the .NET side: it seems that flush () does not do this trick. Here is the minimal phantom code I can reproduce the problem with:

// phantom js "echo server"
var system = require('system'), line;

var line = system.stdin.readLine();
system.stdout.writeLine(line);
system.stdout.flush();

The reason I suspect a flash is because if I either (1) write enough additional content (presumably overflowing the buffer) after the first call to flush (), or (2), run the flush () command with the phantom call. exit (), the .NET process can see the data in a standard format.

What am I doing wrong? Is this a known bug? I am using phantomjs 2.0.0.0.

+4
source share

All Articles