browserless 10.10.0 → 10.10.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/package.json +6 -6
- package/src/driver.js +14 -3
- package/src/index.js +7 -3
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "browserless",
|
|
3
3
|
"description": "The headless Chrome/Chromium driver on top of Puppeteer. Take screenshots, generate PDFs, extract text and HTML with a production-ready API.",
|
|
4
4
|
"homepage": "https://browserless.js.org",
|
|
5
|
-
"version": "10.10.
|
|
5
|
+
"version": "10.10.1",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"javascript"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@browserless/errors": "^10.
|
|
38
|
-
"@browserless/goto": "^10.10.
|
|
39
|
-
"@browserless/pdf": "^10.10.
|
|
40
|
-
"@browserless/screenshot": "^10.10.
|
|
37
|
+
"@browserless/errors": "^10.10.1",
|
|
38
|
+
"@browserless/goto": "^10.10.1",
|
|
39
|
+
"@browserless/pdf": "^10.10.1",
|
|
40
|
+
"@browserless/screenshot": "^10.10.1",
|
|
41
41
|
"debug-logfmt": "~1.4.7",
|
|
42
42
|
"kill-process-group": "~1.0.13",
|
|
43
43
|
"p-reflect": "~2.1.0",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"timeout": "2m",
|
|
68
68
|
"workerThreads": false
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "32f6e72bcb489a83ac9659520a3961aeb97c47b7"
|
|
71
71
|
}
|
package/src/driver.js
CHANGED
|
@@ -71,16 +71,27 @@ const getPid = subprocess => {
|
|
|
71
71
|
|
|
72
72
|
const close = async (subprocess, { signal = 'SIGKILL', ...debugOpts } = {}) => {
|
|
73
73
|
const pid = getPid(subprocess)
|
|
74
|
-
|
|
74
|
+
const hasDisconnect = subprocess && typeof subprocess.disconnect === 'function'
|
|
75
|
+
const hasClose = subprocess && typeof subprocess.close === 'function'
|
|
76
|
+
|
|
77
|
+
if (pid === undefined && !hasDisconnect && !hasClose) return
|
|
75
78
|
|
|
76
79
|
// It's necessary to call `browser.close` for removing temporal files associated
|
|
77
80
|
// and remove listeners attached to the main process; check
|
|
78
81
|
// - https://github.com/puppeteer/puppeteer/blob/778ac92469d66c542c3c12fe0aa23703dd6315c2/src/node/BrowserRunner.ts#L146
|
|
79
82
|
// - https://github.com/puppeteer/puppeteer/blob/69d85e874416d62de6e821bef30e5cebcfd42f15/src/node/BrowserRunner.ts#L189
|
|
80
|
-
await pReflect(
|
|
83
|
+
await pReflect(
|
|
84
|
+
pid === undefined
|
|
85
|
+
? hasDisconnect
|
|
86
|
+
? subprocess.disconnect()
|
|
87
|
+
: subprocess.close()
|
|
88
|
+
: hasClose
|
|
89
|
+
? subprocess.close()
|
|
90
|
+
: killProcessGroup(subprocess, signal)
|
|
91
|
+
)
|
|
81
92
|
|
|
82
93
|
debug('close', { pid, signal, ...debugOpts })
|
|
83
|
-
return { pid }
|
|
94
|
+
return pid === undefined ? {} : { pid }
|
|
84
95
|
}
|
|
85
96
|
|
|
86
97
|
module.exports = { spawn, pid: getPid, close, defaultArgs }
|
package/src/index.js
CHANGED
|
@@ -14,9 +14,8 @@ const { AbortError } = pRetry
|
|
|
14
14
|
|
|
15
15
|
const driver = require('./driver')
|
|
16
16
|
|
|
17
|
-
const lock = withLock()
|
|
18
|
-
|
|
19
17
|
module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
18
|
+
const lock = withLock()
|
|
20
19
|
const goto = createGoto({ timeout: globalTimeout, ...launchOpts })
|
|
21
20
|
const { defaultViewport } = goto
|
|
22
21
|
|
|
@@ -123,7 +122,12 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
123
122
|
|
|
124
123
|
try {
|
|
125
124
|
page = await createPage(name)
|
|
126
|
-
setTimeout(() =>
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
closePage(page, name).catch(error => {
|
|
127
|
+
const { message, code, name } = ensureError(error)
|
|
128
|
+
debug('closePage:timeout:error', { message, code, name })
|
|
129
|
+
})
|
|
130
|
+
}, timeout).unref()
|
|
127
131
|
const value = await fn(page, goto)(...args)
|
|
128
132
|
await closePage(page, `${name}:success`)
|
|
129
133
|
return value
|