@browserless.io/browserless 2.18.0 → 2.19.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.
@@ -255,12 +255,16 @@ export class BrowserManager {
255
255
  },
256
256
  });
257
257
  if (response.ok) {
258
+ const externalUrl = new URL(serverAddress);
259
+ const protocol = externalUrl.protocol === 'https:' ? 'wss' : 'ws';
258
260
  const body = await response.json();
259
261
  for (const page of body) {
262
+ const devtoolsFrontendUrl = `/devtools/inspector.html?${protocol}=${externalUrl.host}${externalUrl.pathname}/devtools/page/${page.id}`;
260
263
  sessions.push({
261
264
  ...sessions[0],
262
265
  ...page,
263
266
  browserWSEndpoint: wsEndpoint,
267
+ devtoolsFrontendUrl,
264
268
  });
265
269
  }
266
270
  }
@@ -299,8 +303,8 @@ export class BrowserManager {
299
303
  global.setTimeout(() => {
300
304
  const session = this.browsers.get(browser);
301
305
  if (session) {
302
- this.log.trace(`Timer hit for "${session.id}"`),
303
- this.close(browser, session);
306
+ this.log.trace(`Timer hit for "${session.id}"`);
307
+ this.close(browser, session);
304
308
  }
305
309
  }, timeout),
306
310
  );
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-unused-expressions */
1
2
  import {
2
3
  Config,
3
4
  Hooks,
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-unused-expressions */
1
2
  import {
2
3
  Browserless,
3
4
  Config,
@@ -4,6 +4,7 @@ import { default as Page, QuerySchema } from '../../../shared/page.ws.js';
4
4
  export default class ChromePageWebSocketRoute extends Page {
5
5
  name = BrowserlessRoutes.ChromePageWebSocketRoute;
6
6
  browser = ChromeCDP;
7
+ auth = false;
7
8
  }
8
9
 
9
10
  export { QuerySchema };
package/src/server.ts CHANGED
@@ -415,7 +415,10 @@ export class HTTPServer extends EventEmitter {
415
415
  public async shutdown(): Promise<void> {
416
416
  this.logger.info(`HTTP Server is shutting down`);
417
417
  await new Promise((r) => this.server.close(r));
418
- this.server && this.server.removeAllListeners();
418
+
419
+ if (this.server) {
420
+ this.server.removeAllListeners();
421
+ }
419
422
 
420
423
  // @ts-ignore garbage collect this reference
421
424
  this.server = null;
@@ -45,6 +45,7 @@ export default class ChromiumJSONVersionGetRoute extends HTTPRoute {
45
45
  }
46
46
  return jsonResponse(res, 200, this.cachedJSON);
47
47
  } catch (err) {
48
+ logger.warn(`Error handling request`, err);
48
49
  return writeResponse(
49
50
  res,
50
51
  500,
@@ -38,7 +38,7 @@ export default async ({
38
38
  const close = (pid?: number) => {
39
39
  if (closed) return;
40
40
  if (pid) process.kill(pid, 'SIGINT');
41
- timeoutId && clearTimeout(timeoutId);
41
+ if (timeoutId) clearTimeout(timeoutId);
42
42
  closed = true;
43
43
  timeoutId = null;
44
44
  };