peerigon/phridge

Phridge not receiving messages via phantom's stdout on Ubuntu

frank-weindel opened this issue · 3 comments

I've been spending most of my day tracking down this issue. I'm still not sure of the root cause but I was able to figure out a workaround via a lucky guess.

The latest version of phridge works great when running my node application on a mac. However, when trying to run it on an Ubuntu linux machine Phridge never receives the "message from node: hi" prompt and so the spawn() promise is never resolved (or rejected for that matter). Phridge is successfully launching phantom its just not getting the stdout from phantom.

After spending hours messing with Phridge code trying to get some response from phantom, I decided to try force flushing stdout from within phantom. I had no idea this would work or even be a valid operation on phantom's stream object, but adding the following statement after every writeLine() in lib/phantom/start.js resolves the issue:

system.stdout.flush();

Again I have no idea why this statement is required on the linux machine and not the mac. Any ideas?

Here's some version info:

  • node: 0.10.28
  • phantomjs: 1.9.0 (special development build)
  • Ubuntu: 11.10
  • Phridge: 1.0.6

I've created a pull request with this fix for your review. This fix causes no issues on mac as far as I can tell.

That's strange... it runs perfectly in my Vagrant machine (Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)). Travis isn't complaining either...

Do you have a reference of the flush()-method? I don't know how Phantomjs' stdout streams are implemented, but it could be caused by a buffer not being emptied?

Why do you use a special development build? Is the same problem persistent with regular Phantomjs versions?

We were using a special build that worked with web fonts. That might have been the issue. We've since found another way to load fonts into phantom and are using an official release (1.9.7). We aren't seeing this issue anymore. I'll close this, but maybe someone else will encounter this issue and find this helpful.

👍