browserless 9.12.4 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md CHANGED
File without changes
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "browserless",
3
3
  "description": "The headless Chrome/Chromium performance driver for Node.js",
4
4
  "homepage": "https://browserless.js.org",
5
- "version": "9.12.4",
5
+ "version": "10.0.1",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -31,10 +31,10 @@
31
31
  "text"
32
32
  ],
33
33
  "dependencies": {
34
- "@browserless/errors": "^9.12.4",
35
- "@browserless/goto": "^9.12.4",
36
- "@browserless/pdf": "^9.12.4",
37
- "@browserless/screenshot": "^9.12.4",
34
+ "@browserless/errors": "^10.0.0",
35
+ "@browserless/goto": "^10.0.1",
36
+ "@browserless/pdf": "^10.0.1",
37
+ "@browserless/screenshot": "^10.0.1",
38
38
  "debug-logfmt": "~1.0.4",
39
39
  "kill-process-group": "~1.0.4",
40
40
  "p-reflect": "~2.1.0",
@@ -44,8 +44,9 @@
44
44
  "superlock": "~1.0.2"
45
45
  },
46
46
  "devDependencies": {
47
- "@browserless/test": "^9.11.0",
47
+ "@browserless/test": "^10.0.1",
48
48
  "ava": "latest",
49
+ "execa": "5",
49
50
  "ps-list": "7"
50
51
  },
51
52
  "engines": {
@@ -54,14 +55,14 @@
54
55
  "files": [
55
56
  "src"
56
57
  ],
57
- "scripts": {
58
- "test": "ava"
59
- },
60
58
  "license": "MIT",
61
59
  "ava": {
62
60
  "serial": true,
63
61
  "timeout": "30s",
64
62
  "workerThreads": false
65
63
  },
66
- "gitHead": "5b81d2e12abab0726176894365f4fb4b4efd6580"
67
- }
64
+ "gitHead": "d9b765f342e2e51a31c210bf31cd4ddc504f78ed",
65
+ "scripts": {
66
+ "test": "ava"
67
+ }
68
+ }
package/src/driver.js CHANGED
@@ -6,13 +6,12 @@ const requireOneOf = require('require-one-of')
6
6
  const pReflect = require('p-reflect')
7
7
 
8
8
  // flags explained: https://peter.sh/experiments/chromium-command-line-switches
9
- // default flags: https://github.com/puppeteer/puppeteer/blob/edb01972b9606d8b05b979a588eda0d622315981/src/node/Launcher.ts#L183
9
+ // default flags: https://github.com/puppeteer/puppeteer/blob/0d2c42a1c47c7cc5293d9664121180b35c4cdf65/packages/puppeteer-core/src/node/ChromeLauncher.ts#L166
10
10
  // AWS Lambda flags: https://github.com/alixaxel/chrome-aws-lambda/blob/78fdbf1b9b9a439883dc2fe747171a765b835031/source/index.ts#L94
11
11
  const defaultArgs = [
12
12
  '--autoplay-policy=user-gesture-required', // https://source.chromium.org/search?q=lang:cpp+symbol:kAutoplayPolicy&ss=chromium
13
13
  '--disable-blink-features=AutomationControlled', // https://blog.m157q.tw/posts/2020/09/11/bypass-cloudflare-detection-while-using-selenium-with-chromedriver/
14
14
  '--disable-cloud-import',
15
- '--disable-component-update', // https://source.chromium.org/search?q=lang:cpp+symbol:kDisableComponentUpdate&ss=chromium
16
15
  '--disable-domain-reliability', // https://source.chromium.org/search?q=lang:cpp+symbol:kDisableDomainReliability&ss=chromium
17
16
  '--disable-features=AudioServiceOutOfProcess,IsolateOrigins,site-per-process', // https://source.chromium.org/search?q=file:content_features.cc&ss=chromium
18
17
  '--disable-gesture-typing',
@@ -31,23 +30,22 @@ const defaultArgs = [
31
30
  '--enable-async-dns',
32
31
  '--enable-simple-cache-backend',
33
32
  '--enable-tcp-fast-open',
34
- '--enable-webgl',
35
33
  '--force-webrtc-ip-handling-policy=default_public_interface_only',
36
34
  '--ignore-gpu-blocklist', // https://source.chromium.org/search?q=lang:cpp+symbol:kIgnoreGpuBlocklist&ss=chromium
37
35
  '--no-default-browser-check', // https://source.chromium.org/search?q=lang:cpp+symbol:kNoDefaultBrowserCheck&ss=chromium
38
36
  '--no-pings', // https://source.chromium.org/search?q=lang:cpp+symbol:kNoPings&ss=chromium
39
37
  '--no-sandbox', // https://source.chromium.org/search?q=lang:cpp+symbol:kNoSandbox&ss=chromium
40
38
  '--no-zygote', // https://source.chromium.org/search?q=lang:cpp+symbol:kNoZygote&ss=chromium
41
- '--prerender-from-omnibox=disabled',
42
- '--use-gl=swiftshader' // https://source.chromium.org/search?q=lang:cpp+symbol:kUseGl&ss=chromium
39
+ '--prerender-from-omnibox=disabled'
43
40
  ]
44
41
 
45
42
  const spawn = ({
46
43
  puppeteer = requireOneOf(['puppeteer', 'puppeteer-core', 'puppeteer-firefox']),
47
44
  mode = 'launch',
48
45
  args = defaultArgs,
46
+ headless = 'new',
49
47
  ...launchOpts
50
- } = {}) => puppeteer[mode]({ ignoreHTTPSErrors: true, args, ...launchOpts })
48
+ } = {}) => puppeteer[mode]({ ignoreHTTPSErrors: true, args, headless, ...launchOpts })
51
49
 
52
50
  const getPid = subprocess => {
53
51
  if ('pid' in subprocess) return subprocess.pid
package/src/index.js CHANGED
@@ -49,7 +49,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
49
49
  debug('spawn', {
50
50
  respawn: isRespawn,
51
51
  pid: driver.pid(browser) || launchOpts.mode,
52
- version: await browser.version()
52
+ version: await browser.version().catch(() => {})
53
53
  })
54
54
  })
55
55
 
@@ -63,7 +63,6 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
63
63
 
64
64
  const getBrowser = async () => {
65
65
  if (isClosed) return browserProcessPromise
66
-
67
66
  const browserProcess = await lock(async () => {
68
67
  const browserProcess = await browserProcessPromise
69
68
  if (browserProcess.isConnected()) return browserProcess
@@ -78,14 +77,6 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
78
77
 
79
78
  const getBrowserContext = () => _contextPromise
80
79
 
81
- getBrowserContext().then(context => {
82
- const browserProcess = context.browser()
83
- browserProcess.once('disconnected', async () => {
84
- await getBrowser()
85
- _contextPromise = createBrowserContext(contextOpts)
86
- })
87
- })
88
-
89
80
  const createPage = async () => {
90
81
  const [browserProcess, browserContext] = await Promise.all([
91
82
  getBrowser(),
@@ -185,7 +176,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
185
176
  }
186
177
  }
187
178
 
188
- return { createContext, respawn, browser: getBrowser, close }
179
+ return { createContext, respawn, browser: getBrowser, close, isClosed: () => isClosed }
189
180
  }
190
181
 
191
182
  module.exports.driver = driver