browserless 9.11.1 → 9.11.2-beta.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/LICENSE.md +0 -0
- package/package.json +5 -6
- package/src/index.js +40 -37
package/LICENSE.md
CHANGED
|
File without changes
|
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.11.
|
|
5
|
+
"version": "9.11.2-beta.0",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -53,14 +53,13 @@
|
|
|
53
53
|
"files": [
|
|
54
54
|
"src"
|
|
55
55
|
],
|
|
56
|
-
"scripts": {
|
|
57
|
-
"test": "ava"
|
|
58
|
-
},
|
|
59
56
|
"license": "MIT",
|
|
60
57
|
"ava": {
|
|
61
58
|
"serial": true,
|
|
62
59
|
"timeout": "30s",
|
|
63
60
|
"workerThreads": false
|
|
64
61
|
},
|
|
65
|
-
"
|
|
66
|
-
|
|
62
|
+
"scripts": {
|
|
63
|
+
"test": "ava"
|
|
64
|
+
}
|
|
65
|
+
}
|
package/src/index.js
CHANGED
|
@@ -107,46 +107,49 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
const withPage =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const task = () =>
|
|
129
|
-
pRetry(run, {
|
|
130
|
-
retries: retry,
|
|
131
|
-
onFailedAttempt: async error => {
|
|
132
|
-
debug('onFailedAttempt', { name: error.name, code: error.code, isRejected })
|
|
133
|
-
if (error.name === 'AbortError') throw error
|
|
134
|
-
if (isRejected) throw new AbortError()
|
|
135
|
-
if (error.code === 'EBRWSRCONTEXTCONNRESET') {
|
|
136
|
-
_contextPromise = createBrowserContext(contextOpts)
|
|
110
|
+
const withPage =
|
|
111
|
+
(fn, { timeout: evaluateTimeout } = {}) =>
|
|
112
|
+
async (...args) => {
|
|
113
|
+
let isRejected = false
|
|
114
|
+
|
|
115
|
+
async function run () {
|
|
116
|
+
let page
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
page = await createPage(args)
|
|
120
|
+
setTimeout(() => closePage(page), timeout).unref()
|
|
121
|
+
|
|
122
|
+
const value = await fn(page, goto)(...args)
|
|
123
|
+
await closePage(page)
|
|
124
|
+
return value
|
|
125
|
+
} catch (error) {
|
|
126
|
+
await closePage(page)
|
|
127
|
+
if (!isRejected) throw ensureError(error)
|
|
137
128
|
}
|
|
138
|
-
const { message, attemptNumber, retriesLeft } = error
|
|
139
|
-
debug('retry', { attemptNumber, retriesLeft, message })
|
|
140
129
|
}
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
const timeout = evaluateTimeout || contextTimeout || globalTimeout
|
|
144
130
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
131
|
+
const task = () =>
|
|
132
|
+
pRetry(run, {
|
|
133
|
+
retries: retry,
|
|
134
|
+
onFailedAttempt: async error => {
|
|
135
|
+
debug('onFailedAttempt', { name: error.name, code: error.code, isRejected })
|
|
136
|
+
if (error.name === 'AbortError') throw error
|
|
137
|
+
if (isRejected) throw new AbortError()
|
|
138
|
+
if (error.code === 'EBRWSRCONTEXTCONNRESET') {
|
|
139
|
+
_contextPromise = createBrowserContext(contextOpts)
|
|
140
|
+
}
|
|
141
|
+
const { message, attemptNumber, retriesLeft } = error
|
|
142
|
+
debug('retry', { attemptNumber, retriesLeft, message })
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const timeout = evaluateTimeout || contextTimeout || globalTimeout
|
|
147
|
+
|
|
148
|
+
return pTimeout(task(), timeout, () => {
|
|
149
|
+
isRejected = true
|
|
150
|
+
throw browserTimeout({ timeout })
|
|
151
|
+
})
|
|
152
|
+
}
|
|
150
153
|
|
|
151
154
|
const evaluate = (fn, gotoOpts) =>
|
|
152
155
|
withPage(
|