Zirak/SO-ChatBot

Use promises

Opened this issue · 2 comments

Zirak commented

Check first if they're available under nightmare. If they are, no reason not to.

Nightmare 2.1.3 uses a modern version of Chromium via Electron, and so it should support them approximately when the latest stable Chrome does.

Nightmare 1.8.x, which is where we're currently at, uses whatever version of PhantomJS you install locally on your system. Meaning:

  • If you use PhantomJS 1.9.x, you're using WebKit1 JSCore from ~2012 or earlier.
  • If you use PhantomJS 2.0, you're using WebKit2 JSCore from Qt 5.1 or thereabouts. It's still nowhere near as performant as V8 or *monkey from Firefox, but it's close enough to be a decentish reference implementation of a JS core with 2014-ish features... Probably no ES6 support though.
  • If you use PhantomJS 2.1, you're using WebKit2 JSCore from Qt 5.5.1, which is modern with much ES5 support and bugfixes, which has a code heritage of Apple (Safari) --> Qt --> PhantomJS (see here for the latest PhantomJS JSCore source code). However, I don't think Promises are supported.

You could, in theory, move to Nightmare 2.1.3, but then you'd be marrying yourself to the Chromium runtime. While it's nice to have it packaged within the Node ecosystem, I have a preference for Selenium, since it would allow us to have a run-headless.config.js option for selecting the browser to use -- that way the end-user could use run-headless.js for old or new versions of Firefox, Chrome, PhantomJS, or even some other browser like Edge.

I have a lot more thoughts on why not to move to Nightmare 2.1.3 that are in my other issue about using Nightmare 1.8.2.

Also, QtWebKit is not really being maintained by anybody except for security updates and some infrequent pulls from WebKit2's upstream JSCore (which itself is not being extremely well-maintained, especially compared to V8, ChakraCore and FF), because all the developer momentum is behind QWebEngine. QWebEngine, in turn, is an out of process instance of Blink (aka Chromium), and does not support true headlessness.

More info.

To properly support a modern, updated, browser environment, our best way forward may be to rewrite run-headless.js to use Selenium (I can work on that if you want; I'm very familiar with it) and require a modern FF/Chrome/Edge as the browser behind it.