browserless 9.3.21 → 9.4.0
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 +3 -3
- package/src/driver.js +8 -13
- package/src/index.js +4 -6
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.
|
|
5
|
+
"version": "9.4.0",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@browserless/pdf": "^9.3.21",
|
|
37
37
|
"@browserless/screenshot": "^9.3.21",
|
|
38
38
|
"debug-logfmt": "~1.0.4",
|
|
39
|
-
"kill-process-group": "~1.0.
|
|
39
|
+
"kill-process-group": "~1.0.2",
|
|
40
40
|
"mutexify": "~1.4.0",
|
|
41
41
|
"p-reflect": "~2.1.0",
|
|
42
42
|
"p-retry": "~4.6.1",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"timeout": "2m",
|
|
62
62
|
"verbose": true
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "b7b9b8bd304ff3246840c32d024856f122cbf9f3"
|
|
65
65
|
}
|
package/src/driver.js
CHANGED
|
@@ -49,20 +49,15 @@ const spawn = ({
|
|
|
49
49
|
...launchOpts
|
|
50
50
|
} = {}) => puppeteer[mode]({ ignoreHTTPSErrors: true, args, ...launchOpts })
|
|
51
51
|
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
if (
|
|
52
|
+
const pid = subprocess => {
|
|
53
|
+
if ('pid' in subprocess) return subprocess.pid
|
|
54
|
+
const browserProcess = 'process' in subprocess ? subprocess.process() : undefined
|
|
55
|
+
if (browserProcess === undefined || browserProcess === null) return
|
|
56
|
+
return 'pid' in browserProcess ? browserProcess.pid : undefined
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
return subprocess ? subprocess.pid : undefined
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const close = async (input, { signal = 'SIGKILL', ...debugOpts } = {}) => {
|
|
64
|
-
const subprocess = getProcess(input)
|
|
65
|
-
if (!subprocess) return
|
|
59
|
+
const close = async (subprocess, { signal = 'SIGKILL', ...debugOpts } = {}) => {
|
|
60
|
+
if (pid(subprocess) === undefined) return
|
|
66
61
|
|
|
67
62
|
// It's necessary to call `browser.close` for removing temporal files associated
|
|
68
63
|
// and remove listeners attached to the main process; check
|
|
@@ -74,4 +69,4 @@ const close = async (input, { signal = 'SIGKILL', ...debugOpts } = {}) => {
|
|
|
74
69
|
return { pid: subprocess.pid }
|
|
75
70
|
}
|
|
76
71
|
|
|
77
|
-
module.exports = { spawn,
|
|
72
|
+
module.exports = { spawn, pid, close, defaultArgs }
|
package/src/index.js
CHANGED
|
@@ -46,11 +46,9 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
46
46
|
|
|
47
47
|
promise.then(async browser => {
|
|
48
48
|
browser.once('disconnected', getBrowser)
|
|
49
|
-
const pid = driver.getPid(browser)
|
|
50
|
-
|
|
51
49
|
debug('spawn', {
|
|
52
50
|
respawn: isRespawn,
|
|
53
|
-
pid: pid || launchOpts.mode,
|
|
51
|
+
pid: driver.pid(browser) || launchOpts.mode,
|
|
54
52
|
version: await browser.version()
|
|
55
53
|
})
|
|
56
54
|
})
|
|
@@ -99,7 +97,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
99
97
|
getBrowserContext()
|
|
100
98
|
])
|
|
101
99
|
const page = await browserContext.newPage()
|
|
102
|
-
debug('createPage', { pid: driver.
|
|
100
|
+
debug('createPage', { pid: driver.pid(browserProcess), id: browserContext._id })
|
|
103
101
|
return page
|
|
104
102
|
}
|
|
105
103
|
|
|
@@ -110,7 +108,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
110
108
|
getBrowserContext(),
|
|
111
109
|
pReflect(page.close())
|
|
112
110
|
])
|
|
113
|
-
debug('closePage', { pid: driver.
|
|
111
|
+
debug('closePage', { pid: driver.pid(browserProcess), id: browserContext._id })
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
114
|
|
|
@@ -170,7 +168,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
170
168
|
const id = browserContext._id
|
|
171
169
|
await pReflect(browserContext.close())
|
|
172
170
|
|
|
173
|
-
debug('destroyContext', { pid: driver.
|
|
171
|
+
debug('destroyContext', { pid: driver.pid(browserProcess), id })
|
|
174
172
|
}
|
|
175
173
|
|
|
176
174
|
return {
|