Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: drop Node6 support #4654

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions .appveyor.yml
@@ -1,6 +1,5 @@
environment:
matrix:
- nodejs_version: "6.12.3"
- nodejs_version: "8.11.3"

build: off
Expand All @@ -13,6 +12,4 @@ install:
npm run coverage &&
npm run test-doclint &&
npm run test-types
) else (
npm run unit-node6
)
17 changes: 0 additions & 17 deletions .ci/node6/Dockerfile.linux

This file was deleted.

9 changes: 0 additions & 9 deletions .cirrus.yml
@@ -1,15 +1,6 @@
env:
DISPLAY: :99.0

task:
matrix:
- name: Chromium (node6 + linux)
container:
dockerfile: .ci/node6/Dockerfile.linux
xvfb_start_background_script: Xvfb :99 -ac -screen 0 1024x768x24
install_script: npm install --unsafe-perm
test_script: npm run unit-node6

task:
matrix:
- name: Chromium (node8 + linux)
Expand Down
3 changes: 0 additions & 3 deletions .travis.yml
Expand Up @@ -24,13 +24,10 @@ script:
- 'if [ "$NODE8" = "true" ]; then npm run test-types; fi'
- 'if [ "$NODE8" = "true" ]; then npm run bundle; fi'
- 'if [ "$NODE8" = "true" ]; then npm run unit-bundle; fi'
- 'if [ "$NODE6" = "true" ]; then npm run unit-node6; fi'
jobs:
include:
- node_js: "8.11.3"
env: NODE8=true
- node_js: "6.12.3"
env: NODE6=true
before_deploy: "npm run apply-next-version"
deploy:
provider: npm
Expand Down
13 changes: 1 addition & 12 deletions DeviceDescriptors.js
Expand Up @@ -14,15 +14,4 @@
* limitations under the License.
*/

let asyncawait = true;
try {
new Function('async function test(){await 1}');
} catch (error) {
asyncawait = false;
}

// If node does not support async await, use the compiled version.
if (asyncawait)
module.exports = require('./lib/DeviceDescriptors');
else
module.exports = require('./node6/lib/DeviceDescriptors');
module.exports = require('./lib/DeviceDescriptors');
13 changes: 1 addition & 12 deletions Errors.js
Expand Up @@ -14,15 +14,4 @@
* limitations under the License.
*/

let asyncawait = true;
try {
new Function('async function test(){await 1}');
} catch (error) {
asyncawait = false;
}

// If node does not support async await, use the compiled version.
if (asyncawait)
module.exports = require('./lib/Errors');
else
module.exports = require('./node6/lib/Errors');
module.exports = require('./lib/Errors');
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -57,7 +57,8 @@ See [puppeteer vs puppeteer-core](https://github.com/GoogleChrome/puppeteer/blob

### Usage

Note: Puppeteer requires at least Node v6.4.0, but the examples below use async/await which is only supported in Node v7.6.0 or greater.
Note: Prior to v1.18.1, Puppeteer required at least Node v6.4.0. All subsequent versions rely on
Node 8.9.0+. All examples below use async/await which is only supported in Node v7.6.0 or greater.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's codify the supported Node.js versions over time as well. We could say something like:

Puppeteer follows the latest [maintenance LTS](https://github.com/nodejs/Release#release-schedule) version of Node.


Puppeteer will be familiar to people using other browser testing frameworks. You create an instance
of `Browser`, open pages, and then manipulate them with [Puppeteer's API](https://github.com/GoogleChrome/puppeteer/blob/v1.18.1/docs/api.md#).
Expand Down
13 changes: 1 addition & 12 deletions experimental/puppeteer-firefox/DeviceDescriptors.js
Expand Up @@ -14,15 +14,4 @@
* limitations under the License.
*/

let asyncawait = true;
try {
new Function('async function test(){await 1}');
} catch (error) {
asyncawait = false;
}

// If node does not support async await, use the compiled version.
if (asyncawait)
module.exports = require('./lib/DeviceDescriptors');
else
module.exports = require('./node6/lib/DeviceDescriptors');
module.exports = require('./lib/DeviceDescriptors');
8 changes: 4 additions & 4 deletions experimental/puppeteer-firefox/lib/BrowserFetcher.js
Expand Up @@ -82,10 +82,10 @@ function downloadURL(product, platform, host, revision) {
return util.format(downloadURLs[product][platform], host, revision, archiveName(product, platform, revision));
}

const readdirAsync = helper.promisify(fs.readdir.bind(fs));
const mkdirAsync = helper.promisify(fs.mkdir.bind(fs));
const unlinkAsync = helper.promisify(fs.unlink.bind(fs));
const chmodAsync = helper.promisify(fs.chmod.bind(fs));
const readdirAsync = util.promisify(fs.readdir.bind(fs));
const mkdirAsync = util.promisify(fs.mkdir.bind(fs));
const unlinkAsync = util.promisify(fs.unlink.bind(fs));
const chmodAsync = util.promisify(fs.chmod.bind(fs));

function existsAsync(filePath) {
let fulfill = null;
Expand Down
16 changes: 0 additions & 16 deletions experimental/puppeteer-firefox/lib/helper.js
Expand Up @@ -65,22 +65,6 @@ class Helper {
}
}

static promisify(nodeFunction) {
function promisified(...args) {
return new Promise((resolve, reject) => {
function callback(err, ...result) {
if (err)
return reject(err);
if (result.length === 1)
return resolve(result[0]);
return resolve(result);
}
nodeFunction.call(null, ...args, callback);
});
}
return promisified;
}

/**
* @param {!Object} obj
* @return {boolean}
Expand Down
4 changes: 2 additions & 2 deletions experimental/puppeteer-firefox/misc/install-preferences.js
@@ -1,14 +1,14 @@
const os = require('os');
const fs = require('fs');
const path = require('path');
const util = require('util');

// Install browser preferences after downloading and unpacking
// firefox instances.
// Based on: https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Enterprise_deployment_before_60#Configuration
async function installFirefoxPreferences(executablePath) {
const firefoxFolder = path.dirname(executablePath);
const {helper} = require('../lib/helper');
const mkdirAsync = helper.promisify(fs.mkdir.bind(fs));
const mkdirAsync = util.promisify(fs.mkdir.bind(fs));

let prefPath = '';
let configPath = '';
Expand Down
23 changes: 7 additions & 16 deletions index.js
Expand Up @@ -14,25 +14,16 @@
* limitations under the License.
*/

let asyncawait = true;
try {
new Function('async function test(){await 1}');
} catch (error) {
asyncawait = false;
}

if (asyncawait) {
const {helper} = require('./lib/helper');
const api = require('./lib/api');
for (const className in api) {
// Puppeteer-web excludes certain classes from bundle, e.g. BrowserFetcher.
if (typeof api[className] === 'function')
helper.installAsyncStackHooks(api[className]);
}
const {helper} = require('./lib/helper');
const api = require('./lib/api');
for (const className in api) {
// Puppeteer-web excludes certain classes from bundle, e.g. BrowserFetcher.
if (typeof api[className] === 'function')
helper.installAsyncStackHooks(api[className]);
}

// If node does not support async await, use the compiled version.
const Puppeteer = asyncawait ? require('./lib/Puppeteer') : require('./node6/lib/Puppeteer');
const Puppeteer = require('./lib/Puppeteer');
const packageJson = require('./package.json');
const preferredRevision = packageJson.puppeteer.chromium_revision;
const isPuppeteerCore = packageJson.name === 'puppeteer-core';
Expand Down
18 changes: 0 additions & 18 deletions install.js
Expand Up @@ -18,8 +18,6 @@
if (require('./package.json').name === 'puppeteer-core')
return;

buildNode6IfNecessary();

if (process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD) {
logPolitely('**INFO** Skipping Chromium download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" environment variable was found.');
return;
Expand Down Expand Up @@ -109,22 +107,6 @@ function toMegabytes(bytes) {
return `${Math.round(mb * 10) / 10} Mb`;
}

function buildNode6IfNecessary() {
const fs = require('fs');
const path = require('path');

// if this package is installed from NPM, then it already has up-to-date node6
// folder.
if (!fs.existsSync(path.join('utils', 'node6-transform')))
return;
// if async/await is supported, then node6 is not needed.
if (supportsAsyncAwait())
return;
// Re-build node6/ folder.
logPolitely('Building Puppeteer for Node 6');
require(path.join(__dirname, 'utils', 'node6-transform'));
}

function supportsAsyncAwait() {
mathiasbynens marked this conversation as resolved.
Show resolved Hide resolved
try {
new Function('async function test(){await 1}');
Expand Down
12 changes: 6 additions & 6 deletions lib/BrowserFetcher.js
Expand Up @@ -17,10 +17,10 @@
const os = require('os');
const fs = require('fs');
const path = require('path');
const extract = require('extract-zip');
const util = require('util');
const extract = require('extract-zip');
const URL = require('url');
const {helper, assert} = require('./helper');
const {assert} = require('./helper');
const removeRecursive = require('rimraf');
// @ts-ignore
const ProxyAgent = require('https-proxy-agent');
Expand Down Expand Up @@ -64,10 +64,10 @@ function downloadURL(platform, host, revision) {
return util.format(downloadURLs[platform], host, revision, archiveName(platform, revision));
}

const readdirAsync = helper.promisify(fs.readdir.bind(fs));
const mkdirAsync = helper.promisify(fs.mkdir.bind(fs));
const unlinkAsync = helper.promisify(fs.unlink.bind(fs));
const chmodAsync = helper.promisify(fs.chmod.bind(fs));
const readdirAsync = util.promisify(fs.readdir.bind(fs));
const mkdirAsync = util.promisify(fs.mkdir.bind(fs));
const unlinkAsync = util.promisify(fs.unlink.bind(fs));
const chmodAsync = util.promisify(fs.chmod.bind(fs));

function existsAsync(filePath) {
let fulfill = null;
Expand Down
3 changes: 2 additions & 1 deletion lib/DOMWorld.js
Expand Up @@ -15,10 +15,11 @@
*/

const fs = require('fs');
const util = require('util');
const {helper, assert} = require('./helper');
const {LifecycleWatcher} = require('./LifecycleWatcher');
const {TimeoutError} = require('./Errors');
const readFileAsync = helper.promisify(fs.readFile);
const readFileAsync = util.promisify(fs.readFile);

/**
* @unrestricted
Expand Down
5 changes: 3 additions & 2 deletions lib/Launcher.js
Expand Up @@ -15,6 +15,7 @@
*/
const os = require('os');
const path = require('path');
const util = require('util');
const http = require('http');
const https = require('https');
const URL = require('url');
Expand All @@ -30,8 +31,8 @@ const {TimeoutError} = require('./Errors');
const WebSocketTransport = require('./WebSocketTransport');
const PipeTransport = require('./PipeTransport');

const mkdtempAsync = helper.promisify(fs.mkdtemp);
const removeFolderAsync = helper.promisify(removeFolder);
const mkdtempAsync = util.promisify(fs.mkdtemp);
const removeFolderAsync = util.promisify(removeFolder);

const CHROME_PROFILE_PATH = path.join(os.tmpdir(), 'puppeteer_dev_profile-');

Expand Down
4 changes: 3 additions & 1 deletion lib/Page.js
Expand Up @@ -17,6 +17,7 @@
const fs = require('fs');
const EventEmitter = require('events');
const mime = require('mime');
const util = require('util');
const {Events} = require('./Events');
const {Connection} = require('./Connection');
const {Dialog} = require('./Dialog');
Expand All @@ -30,7 +31,8 @@ const {Worker} = require('./Worker');
const {createJSHandle} = require('./JSHandle');
const {Accessibility} = require('./Accessibility');
const {TimeoutSettings} = require('./TimeoutSettings');
const writeFileAsync = helper.promisify(fs.writeFile);

const writeFileAsync = util.promisify(fs.writeFile);

class Page extends EventEmitter {
/**
Expand Down
25 changes: 5 additions & 20 deletions lib/helper.js
Expand Up @@ -16,6 +16,11 @@
const {TimeoutError} = require('./Errors');
const debugError = require('debug')(`puppeteer:error`);
const fs = require('fs');
const util = require('util');

const openAsync = util.promisify(fs.open);
const writeAsync = util.promisify(fs.write);
const closeAsync = util.promisify(fs.close);

class Helper {
/**
Expand Down Expand Up @@ -156,22 +161,6 @@ class Helper {
return typeof obj === 'number' || obj instanceof Number;
}

static promisify(nodeFunction) {
function promisified(...args) {
return new Promise((resolve, reject) => {
function callback(err, ...result) {
if (err)
return reject(err);
if (result.length === 1)
return resolve(result[0]);
return resolve(result);
}
nodeFunction.call(null, ...args, callback);
});
}
return promisified;
}

/**
* @param {!NodeJS.EventEmitter} emitter
* @param {(string|symbol)} eventName
Expand Down Expand Up @@ -254,10 +243,6 @@ class Helper {
}
}

const openAsync = Helper.promisify(fs.open);
const writeAsync = Helper.promisify(fs.write);
const closeAsync = Helper.promisify(fs.close);

/**
* @param {*} value
* @param {string=} message
Expand Down
8 changes: 2 additions & 6 deletions package.json
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"repository": "github:GoogleChrome/puppeteer",
"engines": {
"node": ">=6.4.0"
"node": ">=8.9.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a practical concern, is there anything from 7 that would break us?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. I picked 8 here since it's an LTS release with a clear lifetime.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Turns out this only produces a warning.

},
"puppeteer": {
"chromium_revision": "673587"
Expand All @@ -15,14 +15,11 @@
"funit": "BROWSER=firefox node test/test.js",
"debug-unit": "node --inspect-brk test/test.js",
"test-doclint": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js",
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && npm run test-node6-transformer && npm run test-types",
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && npm run test-types",
"install": "node install.js",
"lint": "([ \"$CI\" = true ] && eslint --quiet -f codeframe . || eslint .) && npm run tsc && npm run doc",
"doc": "node utils/doclint/cli.js",
"coverage": "cross-env COVERAGE=true npm run unit",
"test-node6-transformer": "node utils/node6-transform/test/test.js",
"build": "node utils/node6-transform/index.js && node utils/doclint/generate_types",
"unit-node6": "node node6/test/test.js",
"tsc": "tsc -p .",
"prepublishOnly": "npm run build",
"apply-next-version": "node utils/apply_next_version.js",
Expand Down Expand Up @@ -63,7 +60,6 @@
},
"browser": {
"./lib/BrowserFetcher.js": false,
"./node6/lib/Puppeteer": false,
"ws": "./utils/browser/WebSocket",
"fs": false,
"child_process": false,
Expand Down