Zirak / SO-ChatBot

Other
124 stars 62 forks source link

Use Nightmare.js 1.8.2 #266

Open allquixotic opened 8 years ago

allquixotic commented 8 years ago

Reference my commit here to my forked repo. Too lazy to make a PR for a one-line change.

Just a good idea to keep external libs up-to-date...

A really long, unnecessary digression from someone who runs the bot in production

But not too up-to-date!! In this case, the latest upstream Nightmare.js is 2.1.3, but the entire 2.x series uses Electron instead of PhantomJS. This is fine for those hosting a bot on Windows or a Linux/OS X desktop with a GUI, but for those of us running it "in production" on a headless server, this means we have to separately set up and maintain an Xvfb instance, which sucks for various reasons (possibly interferes with other X servers on the same box, incurs overhead, requires a bunch of X11 deps, etc.) That's because Electron is not currently able to run truly headless; it depends on an X server on Linux.

So right now, even though using V8 instead of WebKit JSCore sounds awfully tantalizing, I'm still moved to continue to drive the bot using PhantomJS instead of Electron, so I recommend not going to Nightmare 2.x until Electron is truly headless.

Otherwise, I mean, you might as well just install chrom(ium,e) or Firefox stable on your "pseudo-headless" Linux box, start up Xvfb, and rewrite run-headless.js to drive Firefox or Chrome using Selenium. That's what I did way back in the day (albeit using a Java-based driver).

That way, you can stay on the absolute bleeding edge of JS/HTML/CSS/DOM/codecs support, and you're not beholden on a project like Electron to integrate upstream builds of Chromium (which surely comes with some nonzero delay). Heck, you could even use FF/Chrome nightlies with Selenium, if you wanted to test drive the very latest JS features using the JS commands of the bot...

But, all of that is basically to say that, I'm very happy as a bot sysadmin to avoid having to tangle with X11 at all, and currently the only way to do that is to use PhantomJS, and I feel personally that this outweighs the benefits and drawbacks of the alternative of using Electron (basically equivalent to using Selenium/Chromium, but with a slight version delay) or Selenium (more flexible to let you use all kinds of browsers, including PhantomJS, but arguably less "integrated" into the Node stuff than Nightmare.js).

TL;DR: Without completely upsetting the headless apple cart, we can at least update the version of Nightmare being used to the latest, even if it only solves an issue with a feature we don't even use.

Zirak commented 8 years ago

If latest nightmare is using electron then I'll throw it out and find something else, or just pure phantom (or slimer if it's usable).

The point of using it wasn't being bleeding edge, it was being headless.

allquixotic commented 8 years ago

SlimerJS is still not headless, as far as I can tell.

"Pure phantom" is not a good idea, IMO. PhantomJS project and its dependency on QtWebKit is very fragile. They have a small number of devs that could go inactive and lead to an unmaintained platform at any point. We depend on:

Zirak commented 8 years ago

To address the issue's topic: For those npm installing or npm updateing from the directory you'll get the latest version in the 1.8.x releases of Nightmare, that's the meaning of ^1.8.1 in the package.json.

About the headlessness: We've (allquixotic and I) talked about it in chat. I think that since practically nobody uses the bot in headless mode we're fine with just keeping it at an older version, or at worse with wrapping phantom with a small script. allquixotic didn't like the prospect as much, and may come up with a Selenium based idea. Cool.

somebody1234 commented 8 years ago

Note: They're working on making Nightmare headless again.