browserless 14.1.3 → 14.1.4

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/index.js +5 -5
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": "14.1.3",
5
+ "version": "14.1.4",
6
6
  "types": "index.d.ts",
7
7
  "main": "src/index.js",
8
8
  "author": {
@@ -36,9 +36,9 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@browserless/errors": "14.0.22",
39
- "@browserless/goto": "14.1.2",
40
- "@browserless/pdf": "14.1.2",
41
- "@browserless/screenshot": "14.1.2",
39
+ "@browserless/goto": "14.1.4",
40
+ "@browserless/pdf": "14.1.4",
41
+ "@browserless/screenshot": "14.1.4",
42
42
  "debug-logfmt": "~1.4.15",
43
43
  "kill-process-group": "~1.0.16",
44
44
  "p-reflect": "~2.1.0",
@@ -70,5 +70,5 @@
70
70
  "timeout": "2m",
71
71
  "workerThreads": false
72
72
  },
73
- "gitHead": "c45e62a88191f36685a98af337762bc0c7a72953"
73
+ "gitHead": "136b2d9f50772f096aa81af66780c1b625ec2fc1"
74
74
  }
package/src/index.js CHANGED
@@ -122,10 +122,12 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
122
122
  const newBrowserContext = () =>
123
123
  (forwardedContextOpts ?? forwardContextOpts()).then(createBrowserContext)
124
124
  let _contextPromise = newBrowserContext()
125
- let destroyCount = 0
125
+ let isDestroyed = false
126
126
  const pageMetadata = new WeakMap()
127
+ const isAbandoned = () => isClosed || isDestroyed
127
128
 
128
- const getBrowserContext = () => (_contextPromise ??= newBrowserContext())
129
+ const getBrowserContext = () =>
130
+ isDestroyed ? Promise.reject(contextDisconnected()) : _contextPromise
129
131
 
130
132
  const createPage = async name => {
131
133
  const duration = debug.duration('createPage')
@@ -157,8 +159,6 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
157
159
 
158
160
  return async (...args) => {
159
161
  let isRejected = false
160
- const destroysAtStart = destroyCount
161
- const isAbandoned = () => isClosed || destroyCount !== destroysAtStart
162
162
 
163
163
  async function run () {
164
164
  let page
@@ -255,7 +255,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
255
255
  }
256
256
 
257
257
  const destroyContext = async () => {
258
- destroyCount++
258
+ isDestroyed = true
259
259
  const closingContextPromise = _contextPromise
260
260
  const closingContextOpts = forwardedContextOpts
261
261
  _contextPromise = undefined