Skip to content

Commit 11ff374

Browse files
chore: drop Node.js v6 support (puppeteer#5045)
Node.js v6 was end-of-life'd in April, 2019, with AWS Lambda prohibiting updaets to the Node.js v6 runtime since June 30, 2019. This makes it quite safe for us to remove the Node 6 support from the repository.
1 parent c0ba8f9 commit 11ff374

24 files changed

+48
-494
lines changed

.appveyor.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
environment:
22
matrix:
3-
- nodejs_version: "6.12.3"
4-
FLAKINESS_DASHBOARD_NAME: Appveyor Chromium (Win + node6)
5-
- nodejs_version: "8.11.3"
3+
- nodejs_version: "8.16.0"
64
FLAKINESS_DASHBOARD_NAME: Appveyor Chromium (Win + node8)
75
FLAKINESS_DASHBOARD_PASSWORD:
86
secure: g66jP+j6C+hkXLutBV9fdxB5fRJgcQQzy93SgQzXUmcCl/RjkJwnzyHvX0xfCVnv
@@ -13,11 +11,9 @@ install:
1311
- ps: $env:FLAKINESS_DASHBOARD_BUILD_URL="https://ci.appveyor.com/project/aslushnikov/puppeteer/builds/$env:APPVEYOR_BUILD_ID/job/$env:APPVEYOR_JOB_ID"
1412
- ps: Install-Product node $env:nodejs_version
1513
- npm install
16-
- if "%nodejs_version%" == "8.11.3" (
14+
- if "%nodejs_version%" == "8.16.0" (
1715
npm run lint &&
1816
npm run coverage &&
1917
npm run test-doclint &&
2018
npm run test-types
21-
) else (
22-
npm run unit-node6
2319
)

.ci/node6/Dockerfile.linux

-17
This file was deleted.

.cirrus.yml

-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ env:
44
FLAKINESS_DASHBOARD_NAME: Cirrus ${CIRRUS_TASK_NAME}
55
FLAKINESS_DASHBOARD_BUILD_URL: https://cirrus-ci.com/task/${CIRRUS_TASK_ID}
66

7-
task:
8-
matrix:
9-
- name: Chromium (node6 + linux)
10-
container:
11-
dockerfile: .ci/node6/Dockerfile.linux
12-
xvfb_start_background_script: Xvfb :99 -ac -screen 0 1024x768x24
13-
install_script: npm install --unsafe-perm
14-
test_script: npm run unit-node6
15-
167
task:
178
matrix:
189
- name: Chromium (node8 + linux)

.travis.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,18 @@ script:
2424
- 'if [ "$NODE8" = "true" ]; then npm run test-types; fi'
2525
- 'if [ "$NODE8" = "true" ]; then npm run bundle; fi'
2626
- 'if [ "$NODE8" = "true" ]; then npm run unit-bundle; fi'
27-
- 'if [ "$NODE6" = "true" ]; then npm run unit-node6; fi'
2827
jobs:
2928
include:
30-
- node_js: "8.11.3"
29+
- node_js: "8.16.0"
3130
env:
3231
- NODE8=true
3332
- FLAKINESS_DASHBOARD_NAME="Travis Chromium (node8 + linux)"
3433
- FLAKINESS_DASHBOARD_BUILD_URL="${TRAVIS_JOB_WEB_URL}"
35-
- node_js: "8.11.3"
34+
- node_js: "8.16.0"
3635
env:
3736
- FIREFOX=true
3837
- FLAKINESS_DASHBOARD_NAME="Travis Firefox (node8 + linux)"
3938
- FLAKINESS_DASHBOARD_BUILD_URL="${TRAVIS_JOB_WEB_URL}"
40-
- node_js: "6.12.3"
41-
env:
42-
- NODE6=true
43-
- FLAKINESS_DASHBOARD_NAME="Travis Chromium (node6 + linux)"
44-
- FLAKINESS_DASHBOARD_BUILD_URL="${TRAVIS_JOB_WEB_URL}"
4539
before_deploy: "npm run apply-next-version"
4640
deploy:
4741
provider: npm

DeviceDescriptors.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,4 @@
1414
* limitations under the License.
1515
*/
1616

17-
let asyncawait = true;
18-
try {
19-
new Function('async function test(){await 1}');
20-
} catch (error) {
21-
asyncawait = false;
22-
}
23-
24-
// If node does not support async await, use the compiled version.
25-
if (asyncawait)
26-
module.exports = require('./lib/DeviceDescriptors');
27-
else
28-
module.exports = require('./node6/lib/DeviceDescriptors');
17+
module.exports = require('./lib/DeviceDescriptors');

Errors.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,4 @@
1414
* limitations under the License.
1515
*/
1616

17-
let asyncawait = true;
18-
try {
19-
new Function('async function test(){await 1}');
20-
} catch (error) {
21-
asyncawait = false;
22-
}
23-
24-
// If node does not support async await, use the compiled version.
25-
if (asyncawait)
26-
module.exports = require('./lib/Errors');
27-
else
28-
module.exports = require('./node6/lib/Errors');
17+
module.exports = require('./lib/Errors');

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ See [puppeteer vs puppeteer-core](https://github.com/GoogleChrome/puppeteer/blob
5757

5858
### Usage
5959

60-
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.
60+
Puppeteer follows the latest [maintenance LTS](https://github.com/nodejs/Release#release-schedule) version of Node.
61+
62+
Note: Prior to v1.18.1, Puppeteer required at least Node v6.4.0. All subsequent versions rely on
63+
Node 8.9.0+. All examples below use async/await which is only supported in Node v7.6.0 or greater.
6164

6265
Puppeteer will be familiar to people using other browser testing frameworks. You create an instance
6366
of `Browser`, open pages, and then manipulate them with [Puppeteer's API](https://github.com/GoogleChrome/puppeteer/blob/v1.20.0/docs/api.md#).

experimental/puppeteer-firefox/DeviceDescriptors.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,4 @@
1414
* limitations under the License.
1515
*/
1616

17-
let asyncawait = true;
18-
try {
19-
new Function('async function test(){await 1}');
20-
} catch (error) {
21-
asyncawait = false;
22-
}
23-
24-
// If node does not support async await, use the compiled version.
25-
if (asyncawait)
26-
module.exports = require('./lib/DeviceDescriptors');
27-
else
28-
module.exports = require('./node6/lib/DeviceDescriptors');
17+
module.exports = require('./lib/DeviceDescriptors');

experimental/puppeteer-firefox/lib/Page.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const {Dialog} = require('./Dialog');
44
const {TimeoutError} = require('./Errors');
55
const fs = require('fs');
66
const mime = require('mime');
7-
const util = require('util');
87
const EventEmitter = require('events');
98
const {createHandle} = require('./JSHandle');
109
const {Events} = require('./Events');
@@ -15,7 +14,7 @@ const {TimeoutSettings} = require('./TimeoutSettings');
1514
const {NavigationWatchdog} = require('./NavigationWatchdog');
1615
const {Accessibility} = require('./Accessibility');
1716

18-
const writeFileAsync = util.promisify(fs.writeFile);
17+
const writeFileAsync = helper.promisify(fs.writeFile);
1918

2019
class Page extends EventEmitter {
2120
/**

experimental/puppeteer-firefox/lib/helper.js

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ class Helper {
6565
}
6666
}
6767

68+
/**
69+
* @param {function} nodeFunction
70+
* @return {function}
71+
*/
6872
static promisify(nodeFunction) {
6973
function promisified(...args) {
7074
return new Promise((resolve, reject) => {

experimental/puppeteer-firefox/misc/install-preferences.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
const os = require('os');
22
const fs = require('fs');
33
const path = require('path');
4+
const util = require('util');
45

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

1313
let prefPath = '';
1414
let configPath = '';

index.js

+7-16
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17-
let asyncawait = true;
18-
try {
19-
new Function('async function test(){await 1}');
20-
} catch (error) {
21-
asyncawait = false;
22-
}
23-
24-
if (asyncawait) {
25-
const {helper} = require('./lib/helper');
26-
const api = require('./lib/api');
27-
for (const className in api) {
28-
// Puppeteer-web excludes certain classes from bundle, e.g. BrowserFetcher.
29-
if (typeof api[className] === 'function')
30-
helper.installAsyncStackHooks(api[className]);
31-
}
17+
const {helper} = require('./lib/helper');
18+
const api = require('./lib/api');
19+
for (const className in api) {
20+
// Puppeteer-web excludes certain classes from bundle, e.g. BrowserFetcher.
21+
if (typeof api[className] === 'function')
22+
helper.installAsyncStackHooks(api[className]);
3223
}
3324

3425
// If node does not support async await, use the compiled version.
35-
const Puppeteer = asyncawait ? require('./lib/Puppeteer') : require('./node6/lib/Puppeteer');
26+
const Puppeteer = require('./lib/Puppeteer');
3627
const packageJson = require('./package.json');
3728
const preferredRevision = packageJson.puppeteer.chromium_revision;
3829
const isPuppeteerCore = packageJson.name === 'puppeteer-core';

install.js

-29
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
if (require('./package.json').name === 'puppeteer-core')
1919
return;
2020

21-
buildNode6IfNecessary();
22-
2321
if (process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD) {
2422
logPolitely('**INFO** Skipping Chromium download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" environment variable was found.');
2523
return;
@@ -109,34 +107,7 @@ function toMegabytes(bytes) {
109107
return `${Math.round(mb * 10) / 10} Mb`;
110108
}
111109

112-
function buildNode6IfNecessary() {
113-
const fs = require('fs');
114-
const path = require('path');
115-
116-
// if this package is installed from NPM, then it already has up-to-date node6
117-
// folder.
118-
if (!fs.existsSync(path.join('utils', 'node6-transform')))
119-
return;
120-
// if async/await is supported, then node6 is not needed.
121-
if (supportsAsyncAwait())
122-
return;
123-
// Re-build node6/ folder.
124-
logPolitely('Building Puppeteer for Node 6');
125-
require(path.join(__dirname, 'utils', 'node6-transform'));
126-
}
127-
128-
function supportsAsyncAwait() {
129-
try {
130-
new Function('async function test(){await 1}');
131-
} catch (error) {
132-
return false;
133-
}
134-
return true;
135-
}
136-
137110
function generateProtocolTypesIfNecessary(updated) {
138-
if (!supportsAsyncAwait())
139-
return;
140111
const fs = require('fs');
141112
const path = require('path');
142113
if (!fs.existsSync(path.join(__dirname, 'utils', 'protocol-types-generator')))

lib/BrowserFetcher.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
const os = require('os');
1818
const fs = require('fs');
1919
const path = require('path');
20-
const extract = require('extract-zip');
2120
const util = require('util');
21+
const extract = require('extract-zip');
2222
const URL = require('url');
2323
const {helper, assert} = require('./helper');
2424
const removeRecursive = require('rimraf');

lib/Page.js

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const {Worker} = require('./Worker');
3131
const {createJSHandle} = require('./JSHandle');
3232
const {Accessibility} = require('./Accessibility');
3333
const {TimeoutSettings} = require('./TimeoutSettings');
34+
3435
const writeFileAsync = helper.promisify(fs.writeFile);
3536

3637
class Page extends EventEmitter {

lib/helper.js

+4
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ class Helper {
156156
return typeof obj === 'number' || obj instanceof Number;
157157
}
158158

159+
/**
160+
* @param {function} nodeFunction
161+
* @return {function}
162+
*/
159163
static promisify(nodeFunction) {
160164
function promisified(...args) {
161165
return new Promise((resolve, reject) => {

package.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"repository": "github:GoogleChrome/puppeteer",
77
"engines": {
8-
"node": ">=6.4.0"
8+
"node": ">=8.16.0"
99
},
1010
"puppeteer": {
1111
"chromium_revision": "686378"
@@ -15,14 +15,11 @@
1515
"funit": "BROWSER=firefox node test/test.js",
1616
"debug-unit": "node --inspect-brk test/test.js",
1717
"test-doclint": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js",
18-
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && npm run test-node6-transformer && npm run test-types && node utils/testrunner/test/test.js",
18+
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && npm run test-types && node utils/testrunner/test/test.js",
1919
"install": "node install.js",
2020
"lint": "([ \"$CI\" = true ] && eslint --quiet -f codeframe . || eslint .) && npm run tsc && npm run doc",
2121
"doc": "node utils/doclint/cli.js",
2222
"coverage": "cross-env COVERAGE=true npm run unit",
23-
"test-node6-transformer": "node utils/node6-transform/test/test.js",
24-
"build": "node utils/node6-transform/index.js && node utils/doclint/generate_types",
25-
"unit-node6": "node node6/test/test.js",
2623
"tsc": "tsc -p .",
2724
"prepublishOnly": "npm run build",
2825
"apply-next-version": "node utils/apply_next_version.js",
@@ -63,7 +60,6 @@
6360
},
6461
"browser": {
6562
"./lib/BrowserFetcher.js": false,
66-
"./node6/lib/Puppeteer": false,
6763
"ws": "./utils/browser/WebSocket",
6864
"fs": false,
6965
"child_process": false,

test/evaluation.spec.js

+3-12
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616

1717
const utils = require('./utils');
1818

19-
let asyncawait = true;
20-
try {
21-
new Function('async function foo() {await 1}');
22-
} catch (e) {
23-
asyncawait = false;
24-
}
25-
2619
const bigint = typeof BigInt !== 'undefined';
2720

2821
module.exports.addTests = function({testRunner, expect}) {
@@ -74,14 +67,12 @@ module.exports.addTests = function({testRunner, expect}) {
7467
it_fails_ffox('should return undefined for objects with symbols', async({page, server}) => {
7568
expect(await page.evaluate(() => [Symbol('foo4')])).toBe(undefined);
7669
});
77-
(asyncawait ? it : xit)('should work with function shorthands', async({page, server}) => {
78-
// trick node6 transpiler to not touch our object.
79-
// TODO(lushnikov): remove eval once Node6 is dropped.
80-
const a = eval(`({
70+
it('should work with function shorthands', async({page, server}) => {
71+
const a = {
8172
sum(a, b) { return a + b; },
8273

8374
async mult(a, b) { return a * b; }
84-
})`);
75+
};
8576
expect(await page.evaluate(a.sum, 1, 2)).toBe(3);
8677
expect(await page.evaluate(a.mult, 2, 4)).toBe(8);
8778
});

test/headful.spec.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
const path = require('path');
1818
const os = require('os');
1919
const fs = require('fs');
20-
const {helper} = require('../lib/helper');
21-
const rmAsync = helper.promisify(require('rimraf'));
20+
const util = require('util');
2221
const utils = require('./utils');
2322
const {waitEvent} = utils;
24-
const mkdtempAsync = helper.promisify(fs.mkdtemp);
23+
24+
const rmAsync = util.promisify(require('rimraf'));
25+
const mkdtempAsync = util.promisify(fs.mkdtemp);
2526

2627
const TMP_FOLDER = path.join(os.tmpdir(), 'pptr_tmp_folder-');
2728

test/launcher.spec.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,10 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
233233
const browser = await puppeteer.launch(options);
234234
const pages = await browser.pages();
235235
expect(pages.length).toBe(1);
236-
if (pages[0].url() !== server.EMPTY_PAGE)
237-
await pages[0].waitForNavigation();
238-
expect(pages[0].url()).toBe(server.EMPTY_PAGE);
236+
const page = pages[0];
237+
if (page.url() !== server.EMPTY_PAGE)
238+
await page.waitForNavigation();
239+
expect(page.url()).toBe(server.EMPTY_PAGE);
239240
await browser.close();
240241
});
241242
it('should set the default viewport', async() => {

0 commit comments

Comments
 (0)