browserless 9.12.1 → 9.12.2-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 +2 -2
- package/src/index.js +40 -40
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.2-0",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"superlock": "~1.0.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
+
"ps-list": "7",
|
|
47
48
|
"@browserless/test": "^9.11.0",
|
|
48
49
|
"ava": "latest"
|
|
49
50
|
},
|
|
@@ -59,7 +60,6 @@
|
|
|
59
60
|
"timeout": "30s",
|
|
60
61
|
"workerThreads": false
|
|
61
62
|
},
|
|
62
|
-
"gitHead": "5c0063a7426efea722a67aa6e43f0e988a3c8957",
|
|
63
63
|
"scripts": {
|
|
64
64
|
"test": "ava"
|
|
65
65
|
}
|
package/src/index.js
CHANGED
|
@@ -24,7 +24,9 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
24
24
|
|
|
25
25
|
const close = opts => {
|
|
26
26
|
isClosed = true
|
|
27
|
-
return browserProcessPromise
|
|
27
|
+
return browserProcessPromise
|
|
28
|
+
.then(browserProcess => driver.close(browserProcess, opts))
|
|
29
|
+
.catch(() => {})
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
const respawn = () =>
|
|
@@ -107,48 +109,46 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
|
|
110
|
-
const withPage =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
112
|
+
const withPage = (fn, { timeout: evaluateTimeout } = {}) => 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)
|
|
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)
|
|
127
139
|
}
|
|
140
|
+
const { message, attemptNumber, retriesLeft } = error
|
|
141
|
+
debug('retry', { attemptNumber, retriesLeft, message })
|
|
128
142
|
}
|
|
143
|
+
})
|
|
129
144
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
}
|
|
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(
|