browserless 9.12.2-0 → 9.12.3
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 +7 -6
- package/src/index.js +40 -40
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.12.
|
|
5
|
+
"version": "9.12.3",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"superlock": "~1.0.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"ps-list": "7",
|
|
48
47
|
"@browserless/test": "^9.11.0",
|
|
49
|
-
"ava": "latest"
|
|
48
|
+
"ava": "latest",
|
|
49
|
+
"ps-list": "7"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">= 12"
|
|
@@ -54,13 +54,14 @@
|
|
|
54
54
|
"files": [
|
|
55
55
|
"src"
|
|
56
56
|
],
|
|
57
|
+
"scripts": {
|
|
58
|
+
"test": "ava"
|
|
59
|
+
},
|
|
57
60
|
"license": "MIT",
|
|
58
61
|
"ava": {
|
|
59
62
|
"serial": true,
|
|
60
63
|
"timeout": "30s",
|
|
61
64
|
"workerThreads": false
|
|
62
65
|
},
|
|
63
|
-
"
|
|
64
|
-
"test": "ava"
|
|
65
|
-
}
|
|
66
|
+
"gitHead": "94c06dacf906c3573fb6a6980bd5644140212663"
|
|
66
67
|
}
|
package/src/index.js
CHANGED
|
@@ -24,9 +24,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
24
24
|
|
|
25
25
|
const close = opts => {
|
|
26
26
|
isClosed = true
|
|
27
|
-
return browserProcessPromise
|
|
28
|
-
.then(browserProcess => driver.close(browserProcess, opts))
|
|
29
|
-
.catch(() => {})
|
|
27
|
+
return browserProcessPromise.then(browserProcess => driver.close(browserProcess, opts))
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
const respawn = () =>
|
|
@@ -109,46 +107,48 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
109
107
|
}
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
const withPage =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const task = () =>
|
|
131
|
-
pRetry(run, {
|
|
132
|
-
retries: retry,
|
|
133
|
-
onFailedAttempt: async error => {
|
|
134
|
-
debug('onFailedAttempt', { name: error.name, code: error.code, isRejected })
|
|
135
|
-
if (error.name === 'AbortError') throw error
|
|
136
|
-
if (isRejected) throw new AbortError()
|
|
137
|
-
if (error.code === 'EBRWSRCONTEXTCONNRESET') {
|
|
138
|
-
_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
|
+
const value = await fn(page, goto)(...args)
|
|
122
|
+
await closePage(page)
|
|
123
|
+
return value
|
|
124
|
+
} catch (error) {
|
|
125
|
+
await closePage(page)
|
|
126
|
+
if (!isRejected) throw ensureError(error)
|
|
139
127
|
}
|
|
140
|
-
const { message, attemptNumber, retriesLeft } = error
|
|
141
|
-
debug('retry', { attemptNumber, retriesLeft, message })
|
|
142
128
|
}
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
const timeout = evaluateTimeout || contextTimeout || globalTimeout
|
|
146
129
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
130
|
+
const task = () =>
|
|
131
|
+
pRetry(run, {
|
|
132
|
+
retries: retry,
|
|
133
|
+
onFailedAttempt: async error => {
|
|
134
|
+
debug('onFailedAttempt', { name: error.name, code: error.code, isRejected })
|
|
135
|
+
if (error.name === 'AbortError') throw error
|
|
136
|
+
if (isRejected) throw new AbortError()
|
|
137
|
+
if (error.code === 'EBRWSRCONTEXTCONNRESET') {
|
|
138
|
+
_contextPromise = createBrowserContext(contextOpts)
|
|
139
|
+
}
|
|
140
|
+
const { message, attemptNumber, retriesLeft } = error
|
|
141
|
+
debug('retry', { attemptNumber, retriesLeft, message })
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
const timeout = evaluateTimeout || contextTimeout || globalTimeout
|
|
146
|
+
|
|
147
|
+
return pTimeout(task(), timeout, () => {
|
|
148
|
+
isRejected = true
|
|
149
|
+
throw browserTimeout({ timeout })
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
152
|
|
|
153
153
|
const evaluate = (fn, gotoOpts) =>
|
|
154
154
|
withPage(
|