browserless 9.3.18 → 9.3.21
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/README.md +2 -2
- package/package.json +7 -6
- package/src/driver.js +16 -20
- package/src/index.js +2 -2
package/README.md
CHANGED
|
@@ -18,9 +18,9 @@ npm install browserless puppeteer --save
|
|
|
18
18
|
|
|
19
19
|
## License
|
|
20
20
|
|
|
21
|
-
**browserless** © [Microlink](https://microlink.io),
|
|
21
|
+
**browserless** © [Microlink](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/browserless/blob/master/LICENSE.md) License.<br>
|
|
22
22
|
Authored and maintained by [Microlink](https://microlink.io) with help from [contributors](https://github.com/microlinkhq/browserless/contributors).
|
|
23
23
|
|
|
24
24
|
The [logo](https://thenounproject.com/term/browser/288309/) has been designed by [xinh studio](https://xinh.studio).
|
|
25
25
|
|
|
26
|
-
> [microlink.io](https://microlink.io) · GitHub [
|
|
26
|
+
> [microlink.io](https://microlink.io) · GitHub [microlinkhq](https://github.com/microlinkhq) · Twitter [@microlinkhq](https://twitter.com/microlinkhq)
|
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.3.
|
|
5
|
+
"version": "9.3.21",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -31,11 +31,12 @@
|
|
|
31
31
|
"text"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@browserless/errors": "^9.3.
|
|
35
|
-
"@browserless/goto": "^9.3.
|
|
36
|
-
"@browserless/pdf": "^9.3.
|
|
37
|
-
"@browserless/screenshot": "^9.3.
|
|
34
|
+
"@browserless/errors": "^9.3.21",
|
|
35
|
+
"@browserless/goto": "^9.3.21",
|
|
36
|
+
"@browserless/pdf": "^9.3.21",
|
|
37
|
+
"@browserless/screenshot": "^9.3.21",
|
|
38
38
|
"debug-logfmt": "~1.0.4",
|
|
39
|
+
"kill-process-group": "~1.0.1",
|
|
39
40
|
"mutexify": "~1.4.0",
|
|
40
41
|
"p-reflect": "~2.1.0",
|
|
41
42
|
"p-retry": "~4.6.1",
|
|
@@ -60,5 +61,5 @@
|
|
|
60
61
|
"timeout": "2m",
|
|
61
62
|
"verbose": true
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "1cad664def78a0bc695a98bb5e1786fb41ee90f0"
|
|
64
65
|
}
|
package/src/driver.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const killProcessGroup = require('kill-process-group')
|
|
3
4
|
const debug = require('debug-logfmt')('browserless')
|
|
4
5
|
const requireOneOf = require('require-one-of')
|
|
5
6
|
const pReflect = require('p-reflect')
|
|
6
|
-
const { promisify } = require('util')
|
|
7
|
-
|
|
8
|
-
const exec = promisify(require('child_process').exec)
|
|
9
7
|
|
|
10
8
|
// flags explained: https://peter.sh/experiments/chromium-command-line-switches
|
|
11
9
|
// default flags: https://github.com/puppeteer/puppeteer/blob/edb01972b9606d8b05b979a588eda0d622315981/src/node/Launcher.ts#L183
|
|
@@ -51,31 +49,29 @@ const spawn = ({
|
|
|
51
49
|
...launchOpts
|
|
52
50
|
} = {}) => puppeteer[mode]({ ignoreHTTPSErrors: true, args, ...launchOpts })
|
|
53
51
|
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
if (!browserProcess) return null
|
|
59
|
-
return browserProcess.pid
|
|
52
|
+
const getProcess = subprocess => {
|
|
53
|
+
if (!subprocess) return
|
|
54
|
+
if ('process' in subprocess) return subprocess.process()
|
|
55
|
+
if ('pid' in subprocess) return subprocess
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
const getPid = input => {
|
|
59
|
+
const subprocess = getProcess(input)
|
|
60
|
+
return subprocess ? subprocess.pid : undefined
|
|
61
|
+
}
|
|
66
62
|
|
|
67
|
-
const close = async (
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
63
|
+
const close = async (input, { signal = 'SIGKILL', ...debugOpts } = {}) => {
|
|
64
|
+
const subprocess = getProcess(input)
|
|
65
|
+
if (!subprocess) return
|
|
70
66
|
|
|
71
67
|
// It's necessary to call `browser.close` for removing temporal files associated
|
|
72
68
|
// and remove listeners attached to the main process; check
|
|
73
69
|
// - https://github.com/puppeteer/puppeteer/blob/778ac92469d66c542c3c12fe0aa23703dd6315c2/src/node/BrowserRunner.ts#L146
|
|
74
70
|
// - https://github.com/puppeteer/puppeteer/blob/69d85e874416d62de6e821bef30e5cebcfd42f15/src/node/BrowserRunner.ts#L189
|
|
75
|
-
await pReflect(
|
|
71
|
+
await pReflect('close' in subprocess ? subprocess.close() : killProcessGroup(subprocess, signal))
|
|
76
72
|
|
|
77
|
-
debug('close', { pid, signal, ...debugOpts })
|
|
78
|
-
return { pid }
|
|
73
|
+
debug('close', { pid: subprocess.pid, signal, ...debugOpts })
|
|
74
|
+
return { pid: subprocess.pid }
|
|
79
75
|
}
|
|
80
76
|
|
|
81
|
-
module.exports = { spawn, getPid, close, defaultArgs }
|
|
77
|
+
module.exports = { spawn, getPid, getProcess, close, defaultArgs }
|
package/src/index.js
CHANGED
|
@@ -156,8 +156,8 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
156
156
|
const evaluate = (fn, gotoOpts) =>
|
|
157
157
|
wrapError(
|
|
158
158
|
page => async (url, opts) => {
|
|
159
|
-
const { response } = await goto(page, { url, ...gotoOpts, ...opts })
|
|
160
|
-
return fn(page, response)
|
|
159
|
+
const { response, error } = await goto(page, { url, ...gotoOpts, ...opts })
|
|
160
|
+
return fn(page, response, error)
|
|
161
161
|
},
|
|
162
162
|
gotoOpts
|
|
163
163
|
)
|