browserless 9.6.10 → 9.6.12
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/package.json +5 -5
- package/src/driver.js +6 -5
- package/src/index.js +4 -1
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.6.
|
|
5
|
+
"version": "9.6.12",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@browserless/errors": "^9.6.6",
|
|
35
|
-
"@browserless/goto": "^9.6.
|
|
36
|
-
"@browserless/pdf": "^9.6.
|
|
37
|
-
"@browserless/screenshot": "^9.6.
|
|
35
|
+
"@browserless/goto": "^9.6.11",
|
|
36
|
+
"@browserless/pdf": "^9.6.11",
|
|
37
|
+
"@browserless/screenshot": "^9.6.12",
|
|
38
38
|
"debug-logfmt": "~1.0.4",
|
|
39
39
|
"kill-process-group": "~1.0.3",
|
|
40
40
|
"p-reflect": "~2.1.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"timeout": "30s",
|
|
63
63
|
"verbose": true
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "1af45a13ac24009bb4dd5539711258664983c237"
|
|
66
66
|
}
|
package/src/driver.js
CHANGED
|
@@ -49,7 +49,7 @@ const spawn = ({
|
|
|
49
49
|
...launchOpts
|
|
50
50
|
} = {}) => puppeteer[mode]({ ignoreHTTPSErrors: true, args, ...launchOpts })
|
|
51
51
|
|
|
52
|
-
const
|
|
52
|
+
const getPid = subprocess => {
|
|
53
53
|
if ('pid' in subprocess) return subprocess.pid
|
|
54
54
|
const browserProcess = 'process' in subprocess ? subprocess.process() : undefined
|
|
55
55
|
if (browserProcess === undefined || browserProcess === null) return
|
|
@@ -57,7 +57,8 @@ const pid = subprocess => {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
const close = async (subprocess, { signal = 'SIGKILL', ...debugOpts } = {}) => {
|
|
60
|
-
|
|
60
|
+
const pid = getPid(subprocess)
|
|
61
|
+
if (pid === undefined) return
|
|
61
62
|
|
|
62
63
|
// It's necessary to call `browser.close` for removing temporal files associated
|
|
63
64
|
// and remove listeners attached to the main process; check
|
|
@@ -65,8 +66,8 @@ const close = async (subprocess, { signal = 'SIGKILL', ...debugOpts } = {}) => {
|
|
|
65
66
|
// - https://github.com/puppeteer/puppeteer/blob/69d85e874416d62de6e821bef30e5cebcfd42f15/src/node/BrowserRunner.ts#L189
|
|
66
67
|
await pReflect('close' in subprocess ? subprocess.close() : killProcessGroup(subprocess, signal))
|
|
67
68
|
|
|
68
|
-
debug('close', { pid
|
|
69
|
-
return { pid
|
|
69
|
+
debug('close', { pid, signal, ...debugOpts })
|
|
70
|
+
return { pid }
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
module.exports = { spawn, pid, close, defaultArgs }
|
|
73
|
+
module.exports = { spawn, pid: getPid, close, defaultArgs }
|
package/src/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const debug = require('debug-logfmt')('browserless')
|
|
|
6
6
|
const createGoto = require('@browserless/goto')
|
|
7
7
|
const createPdf = require('@browserless/pdf')
|
|
8
8
|
const { withLock } = require('superlock')
|
|
9
|
+
const { randomUUID } = require('crypto')
|
|
9
10
|
const pReflect = require('p-reflect')
|
|
10
11
|
const pTimeout = require('p-timeout')
|
|
11
12
|
const pRetry = require('p-retry')
|
|
@@ -59,7 +60,9 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
59
60
|
let browserProcessPromise = spawn()
|
|
60
61
|
|
|
61
62
|
const createBrowserContext = contextOpts =>
|
|
62
|
-
getBrowser()
|
|
63
|
+
getBrowser()
|
|
64
|
+
.then(browser => browser.createIncognitoBrowserContext(contextOpts))
|
|
65
|
+
.then(context => (context._id = randomUUID()) && context)
|
|
63
66
|
|
|
64
67
|
const getBrowser = async () => {
|
|
65
68
|
if (isClosed) return browserProcessPromise
|