browserless 13.13.0 → 13.16.1

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/index.d.ts CHANGED
@@ -31,7 +31,7 @@ export interface Context {
31
31
  respawn: () => void
32
32
  context: () => Promise<BrowserContext>
33
33
  browser: () => Promise<Browser>
34
- evaluate: <T>(fn: (page: Page, response?: HTTPResponse | undefined, error?: Error) => T | Promise<T>, gotoOpts?: GotoOptions & { keepPage?: boolean, preserveContext?: boolean }) => Promise<T>
34
+ evaluate: <T>(fn: (page: Page, response?: HTTPResponse | undefined, error?: Error) => T | Promise<T>, gotoOpts?: GotoOptions & { keepPage?: boolean }) => Promise<T>
35
35
  goto: (page: Page, opts: GotoOptions & { url: string }) => Promise<GotoResult>
36
36
  html: (url: string, opts?: GotoOptions) => Promise<string>
37
37
  page: (name?: string) => Promise<Page>
@@ -41,7 +41,7 @@ export interface Context {
41
41
  getDevice: (deviceName: string) => Viewport | undefined
42
42
  report: (opts?: { benchmark?: boolean }) => Promise<HardwareInfo>
43
43
  destroyContext: (opts?: { force?: boolean }) => Promise<void>
44
- withPage: <T>(fn: (page: Page, goto: unknown) => Promise<T>, opts?: { timeout?: number, keepPage?: boolean, preserveContext?: boolean }) => Promise<T>
44
+ withPage: <T>(fn: (page: Page, goto: unknown) => Promise<T>, opts?: { timeout?: number, keepPage?: boolean }) => Promise<T>
45
45
  }
46
46
 
47
47
  export interface GotoOptions {
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": "13.13.0",
5
+ "version": "13.16.1",
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": "13.9.23",
39
- "@browserless/goto": "13.12.5",
40
- "@browserless/pdf": "13.12.5",
41
- "@browserless/screenshot": "13.12.5",
39
+ "@browserless/goto": "13.13.1",
40
+ "@browserless/pdf": "13.13.1",
41
+ "@browserless/screenshot": "13.13.1",
42
42
  "debug-logfmt": "~1.4.15",
43
43
  "kill-process-group": "~1.0.16",
44
44
  "p-reflect": "~2.1.0",
@@ -69,5 +69,5 @@
69
69
  "timeout": "2m",
70
70
  "workerThreads": false
71
71
  },
72
- "gitHead": "e118824d6fc40a4d930b58bbe7d449731b5df2aa"
72
+ "gitHead": "71806920d275653c2ed971dc974bef4d7fc65df2"
73
73
  }
package/src/index.js CHANGED
@@ -110,10 +110,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
110
110
  }
111
111
  }
112
112
 
113
- const withPage = (
114
- fn,
115
- { timeout: evaluateTimeout, keepPage = false, preserveContext = false } = {}
116
- ) => {
113
+ const withPage = (fn, { timeout: evaluateTimeout, keepPage = false } = {}) => {
117
114
  const name = fn.name || 'anonymous'
118
115
 
119
116
  return async (...args) => {
@@ -172,13 +169,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
172
169
  // Every attempt builds its own page, so both codes are retryable
173
170
  // inside the existing context: `EBRWSRCONTEXTCONNRESET` covers a
174
171
  // closed page, a detached frame and a destroyed execution context,
175
- // which a fresh page recovers from. Replacing the context is the
176
- // only part a caller that owns it cannot afford, since that closes
177
- // the pages it still holds. Skip that, not the retry.
178
- if (preserveContext) {
179
- debug('retry', { attemptNumber, retriesLeft, message, preserveContext })
180
- return
181
- }
172
+ // which a fresh page recovers from.
182
173
  const previousContextPromise = _contextPromise
183
174
  _contextPromise = createBrowserContext(contextOpts)
184
175
  await pReflect(previousContextPromise.then(ctx => ctx.close()))
@@ -198,7 +189,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
198
189
  const evaluate = (fn, gotoOpts) => {
199
190
  // Both belong to withPage, so they are pulled out rather than spread into
200
191
  // the navigation options.
201
- const { keepPage, preserveContext, ...navigateOpts } = gotoOpts ?? {}
192
+ const { keepPage, ...navigateOpts } = gotoOpts ?? {}
202
193
 
203
194
  return withPage(
204
195
  Object.defineProperty(
@@ -212,7 +203,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
212
203
  writable: false
213
204
  }
214
205
  ),
215
- { ...navigateOpts, keepPage, preserveContext }
206
+ { ...navigateOpts, keepPage }
216
207
  )
217
208
  }
218
209