browserless 9.2.6 → 9.2.13
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/index.js +18 -12
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.2.
|
|
5
|
+
"version": "9.2.13",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@browserless/errors": "^9.1.6",
|
|
35
35
|
"@browserless/goto": "^9.2.6",
|
|
36
36
|
"@browserless/pdf": "^9.2.6",
|
|
37
|
-
"@browserless/screenshot": "^9.2.
|
|
37
|
+
"@browserless/screenshot": "^9.2.9",
|
|
38
38
|
"debug-logfmt": "~1.0.4",
|
|
39
39
|
"mutexify": "~1.3.1",
|
|
40
40
|
"p-reflect": "~2.1.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"timeout": "2m",
|
|
63
63
|
"verbose": true
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "5e3fa535f0c90777bce6354a1db6f292881e2562"
|
|
66
66
|
}
|
package/src/index.js
CHANGED
|
@@ -16,8 +16,8 @@ const driver = require('./driver')
|
|
|
16
16
|
|
|
17
17
|
const lock = mutexify()
|
|
18
18
|
|
|
19
|
-
module.exports = ({ timeout = 30000, ...launchOpts } = {}) => {
|
|
20
|
-
const goto = createGoto({ timeout, ...launchOpts })
|
|
19
|
+
module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
20
|
+
const goto = createGoto({ timeout: globalTimeout, ...launchOpts })
|
|
21
21
|
const { defaultViewport } = goto
|
|
22
22
|
|
|
23
23
|
let isClosed = false
|
|
@@ -40,7 +40,7 @@ module.exports = ({ timeout = 30000, ...launchOpts } = {}) => {
|
|
|
40
40
|
handleSIGINT: false,
|
|
41
41
|
handleSIGTERM: false,
|
|
42
42
|
handleSIGHUP: false,
|
|
43
|
-
timeout,
|
|
43
|
+
timeout: globalTimeout,
|
|
44
44
|
...launchOpts
|
|
45
45
|
})
|
|
46
46
|
|
|
@@ -79,7 +79,7 @@ module.exports = ({ timeout = 30000, ...launchOpts } = {}) => {
|
|
|
79
79
|
return getBrowser()
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
const createContext = async ({ retry = 2 } = {}) => {
|
|
82
|
+
const createContext = async ({ retry = 2, timeout: contextTimeout } = {}) => {
|
|
83
83
|
let contextPromise = createBrowserContext()
|
|
84
84
|
|
|
85
85
|
contextPromise.then(context => {
|
|
@@ -98,12 +98,12 @@ module.exports = ({ timeout = 30000, ...launchOpts } = {}) => {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
const closePage = async page => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
if (page && !page.isClosed()) {
|
|
102
|
+
debug('closePage', await pReflect(page.close()))
|
|
103
|
+
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
const wrapError = (fn, { timeout:
|
|
106
|
+
const wrapError = (fn, { timeout: evaluateTimeout } = {}) => async (...args) => {
|
|
107
107
|
let isRejected = false
|
|
108
108
|
|
|
109
109
|
async function run () {
|
|
@@ -111,12 +111,13 @@ module.exports = ({ timeout = 30000, ...launchOpts } = {}) => {
|
|
|
111
111
|
|
|
112
112
|
try {
|
|
113
113
|
page = await createPage(args)
|
|
114
|
+
setTimeout(() => closePage(page), timeout)
|
|
114
115
|
const value = await fn(page)(...args)
|
|
115
116
|
await closePage(page)
|
|
116
117
|
return value
|
|
117
118
|
} catch (error) {
|
|
118
119
|
await closePage(page)
|
|
119
|
-
throw ensureError(error)
|
|
120
|
+
if (!isRejected) throw ensureError(error)
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
|
|
@@ -132,9 +133,11 @@ module.exports = ({ timeout = 30000, ...launchOpts } = {}) => {
|
|
|
132
133
|
}
|
|
133
134
|
})
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
const timeout = evaluateTimeout || contextTimeout || globalTimeout
|
|
137
|
+
|
|
138
|
+
return pTimeout(task(), timeout, () => {
|
|
136
139
|
isRejected = true
|
|
137
|
-
throw browserTimeout({ timeout
|
|
140
|
+
throw browserTimeout({ timeout })
|
|
138
141
|
})
|
|
139
142
|
}
|
|
140
143
|
|
|
@@ -147,7 +150,10 @@ module.exports = ({ timeout = 30000, ...launchOpts } = {}) => {
|
|
|
147
150
|
gotoOpts
|
|
148
151
|
)
|
|
149
152
|
|
|
150
|
-
const destroyContext = () =>
|
|
153
|
+
const destroyContext = async () => {
|
|
154
|
+
const context = await contextPromise
|
|
155
|
+
debug('destroyContext', await pReflect(context.close()))
|
|
156
|
+
}
|
|
151
157
|
|
|
152
158
|
return {
|
|
153
159
|
respawn,
|