@browserless.io/browserless 2.24.0-beta-5 → 2.25.0-beta-2
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/CHANGELOG.md +17 -1
- package/bin/browserless.js +1 -1
- package/build/browsers/browsers.playwright.d.ts +1 -0
- package/build/browsers/browsers.playwright.js +3 -0
- package/build/browsers/index.d.ts +2 -1
- package/build/browsers/index.js +28 -7
- package/build/http.d.ts +5 -0
- package/build/http.js +1 -0
- package/build/routes/chrome/http/content.post.body.json +8 -8
- package/build/routes/chrome/http/content.post.query.json +4 -0
- package/build/routes/chrome/http/download.post.query.json +4 -0
- package/build/routes/chrome/http/function.post.query.json +4 -0
- package/build/routes/chrome/http/pdf.post.body.json +8 -8
- package/build/routes/chrome/http/pdf.post.query.json +4 -0
- package/build/routes/chrome/http/performance.post.query.json +4 -0
- package/build/routes/chrome/http/scrape.post.body.json +8 -8
- package/build/routes/chrome/http/scrape.post.query.json +4 -0
- package/build/routes/chrome/http/screenshot.post.body.json +8 -8
- package/build/routes/chrome/http/screenshot.post.query.json +4 -0
- package/build/routes/chrome/tests/kill-sessions.spec.d.ts +1 -0
- package/build/routes/chrome/tests/kill-sessions.spec.js +80 -0
- package/build/routes/chrome/ws/browser.query.json +4 -0
- package/build/routes/chrome/ws/cdp.query.json +4 -0
- package/build/routes/chrome/ws/page.query.json +4 -0
- package/build/routes/chrome/ws/playwright.query.json +4 -0
- package/build/routes/chromium/http/content.post.body.json +8 -8
- package/build/routes/chromium/http/content.post.query.json +4 -0
- package/build/routes/chromium/http/download.post.query.json +4 -0
- package/build/routes/chromium/http/function.post.query.json +4 -0
- package/build/routes/chromium/http/pdf.post.body.json +8 -8
- package/build/routes/chromium/http/pdf.post.query.json +4 -0
- package/build/routes/chromium/http/performance.post.query.json +4 -0
- package/build/routes/chromium/http/scrape.post.body.json +8 -8
- package/build/routes/chromium/http/scrape.post.query.json +4 -0
- package/build/routes/chromium/http/screenshot.post.body.json +8 -8
- package/build/routes/chromium/http/screenshot.post.query.json +4 -0
- package/build/routes/chromium/tests/kill-sessions.spec.d.ts +1 -0
- package/build/routes/chromium/tests/kill-sessions.spec.js +80 -0
- package/build/routes/chromium/tests/websocket.spec.js +23 -0
- package/build/routes/chromium/ws/browser.query.json +4 -0
- package/build/routes/chromium/ws/cdp.query.json +4 -0
- package/build/routes/chromium/ws/page.query.json +4 -0
- package/build/routes/chromium/ws/playwright.query.json +4 -0
- package/build/routes/firefox/tests/kill-sessions.spec.d.ts +1 -0
- package/build/routes/firefox/tests/kill-sessions.spec.js +72 -0
- package/build/routes/firefox/ws/playwright.query.json +4 -0
- package/build/routes/management/http/kill.get.d.ts +21 -0
- package/build/routes/management/http/kill.get.js +19 -0
- package/build/routes/management/http/kill.get.query.json +193 -0
- package/build/routes/management/http/meta.get.js +3 -2
- package/build/routes/management/http/sessions.get.query.json +1 -0
- package/build/routes/management/tests/management.spec.js +12 -0
- package/build/routes/webkit/tests/kill-sessions.spec.d.ts +1 -0
- package/build/routes/webkit/tests/kill-sessions.spec.js +72 -0
- package/build/routes/webkit/ws/playwright.query.json +4 -0
- package/build/shared/utils/performance/main.js +2 -1
- package/build/types.d.ts +2 -0
- package/build/types.js +1 -0
- package/build/utils.d.ts +1 -1
- package/build/utils.js +1 -10
- package/package.json +12 -12
- package/src/browsers/browsers.playwright.ts +3 -0
- package/src/browsers/index.ts +33 -12
- package/src/http.ts +6 -0
- package/src/routes/chrome/tests/kill-sessions.spec.ts +99 -0
- package/src/routes/chromium/tests/kill-sessions.spec.ts +99 -0
- package/src/routes/chromium/tests/websocket.spec.ts +29 -0
- package/src/routes/firefox/tests/kill-sessions.spec.ts +99 -0
- package/src/routes/management/http/kill.get.ts +40 -0
- package/src/routes/management/http/meta.get.ts +12 -10
- package/src/routes/management/tests/management.spec.ts +19 -0
- package/src/routes/webkit/tests/kill-sessions.spec.ts +99 -0
- package/src/shared/utils/performance/main.ts +2 -8
- package/src/types.ts +1 -0
- package/src/utils.ts +2 -11
- package/static/docs/swagger.json +297 -10
- package/static/docs/swagger.min.json +296 -9
- package/static/function/client.js +157 -42
- package/static/function/index.html +157 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
# [Latest](https://github.com/browserless/chrome/compare/v2.
|
|
1
|
+
# [Latest](https://github.com/browserless/chrome/compare/v2.24.0...main)
|
|
2
2
|
|
|
3
3
|
- Dependency updates.
|
|
4
4
|
|
|
5
|
+
# [v2.24.0](https://github.com/browserless/chrome/compare/v2.24.0...v2.23.0)
|
|
6
|
+
|
|
7
|
+
- Dependency updates.
|
|
8
|
+
- Supports:
|
|
9
|
+
- puppeteer-core: 23.10.1.
|
|
10
|
+
- playwright-core: 1.49.0, 1.48.2, 1.47.2, 1.46.1, 1.45.3 and 1.44.1.
|
|
11
|
+
- Chromium: 131.0.6778.33.
|
|
12
|
+
- Chrome: 131.0.6778.109.
|
|
13
|
+
- Firefox: 132.0.
|
|
14
|
+
- Webkit: 18.2.
|
|
15
|
+
- New `/meta` API route for getting details about the container (versions, etc).
|
|
16
|
+
- Bump NodeJS to `v22.11.0`.
|
|
17
|
+
- Add `libwebp-dev` for Webkit.
|
|
18
|
+
- Add support for `trackingId` and `/kill/{id}` and `/kill/all`.
|
|
19
|
+
- Prettier, internal fixes and improvements.
|
|
20
|
+
|
|
5
21
|
# [v2.23.0](https://github.com/browserless/chrome/compare/v2.23.0...v2.22.0)
|
|
6
22
|
|
|
7
23
|
- Dependency updates.
|
package/bin/browserless.js
CHANGED
|
@@ -13,6 +13,7 @@ declare class BasePlaywright extends EventEmitter {
|
|
|
13
13
|
protected userDataDir: string | null;
|
|
14
14
|
protected running: boolean;
|
|
15
15
|
protected logger: Logger;
|
|
16
|
+
protected socket: Duplex | null;
|
|
16
17
|
protected proxy: httpProxy<import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>>;
|
|
17
18
|
protected browser: playwright.BrowserServer | null;
|
|
18
19
|
protected browserWSEndpoint: string | null;
|
|
@@ -14,6 +14,7 @@ class BasePlaywright extends EventEmitter {
|
|
|
14
14
|
userDataDir;
|
|
15
15
|
running = false;
|
|
16
16
|
logger;
|
|
17
|
+
socket = null;
|
|
17
18
|
proxy = httpProxy.createProxyServer();
|
|
18
19
|
browser = null;
|
|
19
20
|
browserWSEndpoint = null;
|
|
@@ -48,6 +49,7 @@ class BasePlaywright extends EventEmitter {
|
|
|
48
49
|
async close() {
|
|
49
50
|
if (this.browser) {
|
|
50
51
|
this.logger.info(`Closing ${this.constructor.name} process and all listeners`);
|
|
52
|
+
this.socket?.destroy();
|
|
51
53
|
this.emit('close');
|
|
52
54
|
this.cleanListeners();
|
|
53
55
|
this.browser.close();
|
|
@@ -104,6 +106,7 @@ class BasePlaywright extends EventEmitter {
|
|
|
104
106
|
this.logger.error(`Not yet implemented in ${this.constructor.name}`);
|
|
105
107
|
}
|
|
106
108
|
async proxyWebSocket(req, socket, head) {
|
|
109
|
+
this.socket = socket;
|
|
107
110
|
return new Promise((resolve, reject) => {
|
|
108
111
|
if (!this.browserWSEndpoint) {
|
|
109
112
|
throw new ServerError(`No browserWSEndpoint found, did you launch first?`);
|
|
@@ -50,7 +50,8 @@ export declare class BrowserManager {
|
|
|
50
50
|
ttl: number;
|
|
51
51
|
userDataDir: string | null;
|
|
52
52
|
}[]>;
|
|
53
|
-
close(browser: BrowserInstance, session: BrowserlessSession): Promise<void>;
|
|
53
|
+
close(browser: BrowserInstance, session: BrowserlessSession, force?: boolean): Promise<void>;
|
|
54
|
+
killSessions(target: string): Promise<void>;
|
|
54
55
|
getAllSessions(trackingId?: string): Promise<BrowserlessSessionJSON[]>;
|
|
55
56
|
complete(browser: BrowserInstance): Promise<void>;
|
|
56
57
|
getBrowserForRequest(req: Request, router: BrowserHTTPRoute | BrowserWebsocketRoute, logger: Logger): Promise<BrowserInstance>;
|
package/build/browsers/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { BLESS_PAGE_IDENTIFIER, BadRequest, ChromeCDP, ChromePlaywright, ChromiumCDP, ChromiumPlaywright, FirefoxPlaywright,
|
|
1
|
+
import { BLESS_PAGE_IDENTIFIER, BadRequest, ChromeCDP, ChromePlaywright, ChromiumCDP, ChromiumPlaywright, FirefoxPlaywright, Logger, NotFound, ServerError, WebKitPlaywright, availableBrowsers, convertIfBase64, exists, generateDataDir, makeExternalURL, noop, parseBooleanParam, parseStringParam, pwVersionRegex, } from '@browserless.io/browserless';
|
|
2
2
|
import { deleteAsync } from 'del';
|
|
3
|
+
import micromatch from 'micromatch';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
export class BrowserManager {
|
|
5
6
|
config;
|
|
@@ -153,7 +154,7 @@ export class BrowserManager {
|
|
|
153
154
|
initialConnectURL: new URL(session.initialConnectURL, serverAddress)
|
|
154
155
|
.href,
|
|
155
156
|
killURL: session.id
|
|
156
|
-
? makeExternalURL(serverAddress,
|
|
157
|
+
? makeExternalURL(serverAddress, '/kill/', session.id)
|
|
157
158
|
: null,
|
|
158
159
|
running: browser.isRunning(),
|
|
159
160
|
timeAliveMs: Date.now() - session.startedOn,
|
|
@@ -185,20 +186,20 @@ export class BrowserManager {
|
|
|
185
186
|
}
|
|
186
187
|
return sessions;
|
|
187
188
|
}
|
|
188
|
-
async close(browser, session) {
|
|
189
|
+
async close(browser, session, force = false) {
|
|
189
190
|
const now = Date.now();
|
|
190
191
|
const keepUntil = browser.keepUntil();
|
|
191
192
|
const connected = session.numbConnected;
|
|
192
193
|
const hasKeepUntil = keepUntil > now;
|
|
193
|
-
const keepOpen = connected > 0 || hasKeepUntil;
|
|
194
|
+
const keepOpen = (connected > 0 || hasKeepUntil) && !force;
|
|
194
195
|
const cleanupACtions = [];
|
|
195
196
|
const priorTimer = this.timers.get(session.id);
|
|
196
197
|
if (priorTimer) {
|
|
197
198
|
this.log.info(`Deleting prior keep-until timer for "${session.id}"`);
|
|
198
199
|
global.clearTimeout(priorTimer);
|
|
199
200
|
}
|
|
200
|
-
this.log.info(`${session.numbConnected} Client(s) are currently connected, Keep-until: ${keepUntil}`);
|
|
201
|
-
if (hasKeepUntil) {
|
|
201
|
+
this.log.info(`${session.numbConnected} Client(s) are currently connected, Keep-until: ${keepUntil}, force: ${force}`);
|
|
202
|
+
if (!force && hasKeepUntil) {
|
|
202
203
|
const timeout = keepUntil - now;
|
|
203
204
|
this.log.trace(`Setting timer ${timeout.toLocaleString()} for "${session.id}"`);
|
|
204
205
|
this.timers.set(session.id, global.setTimeout(() => {
|
|
@@ -220,6 +221,23 @@ export class BrowserManager {
|
|
|
220
221
|
await Promise.all(cleanupACtions.map((a) => a()));
|
|
221
222
|
}
|
|
222
223
|
}
|
|
224
|
+
async killSessions(target) {
|
|
225
|
+
this.log.info(`killSessions invoked target: "${target}"`);
|
|
226
|
+
const sessions = Array.from(this.browsers);
|
|
227
|
+
let closed = 0;
|
|
228
|
+
for (const [browser, session] of sessions) {
|
|
229
|
+
if (session.trackingId === target ||
|
|
230
|
+
session.id === target ||
|
|
231
|
+
target === 'all') {
|
|
232
|
+
this.log.info(`Closing browser via killSessions BrowserId: "${session.id}", trackingId: "${session.trackingId}"`);
|
|
233
|
+
this.close(browser, session, true);
|
|
234
|
+
closed++;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (closed === 0 && target !== 'all') {
|
|
238
|
+
throw new NotFound(`Couldn't locate session for id: "${target}"`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
223
241
|
async getAllSessions(trackingId) {
|
|
224
242
|
const sessions = Array.from(this.browsers);
|
|
225
243
|
let formattedSessions = [];
|
|
@@ -259,9 +277,12 @@ export class BrowserManager {
|
|
|
259
277
|
if (trackingId.length > 32) {
|
|
260
278
|
throw new BadRequest(`TrackingId "${trackingId}" must be less than 32 characters`);
|
|
261
279
|
}
|
|
262
|
-
if (
|
|
280
|
+
if (!micromatch.isMatch(trackingId, '+([0-9a-zA-Z-_])')) {
|
|
263
281
|
throw new BadRequest(`trackingId contains invalid characters`);
|
|
264
282
|
}
|
|
283
|
+
if (trackingId === 'all') {
|
|
284
|
+
throw new BadRequest(`trackingId cannot be the reserved word "all"`);
|
|
285
|
+
}
|
|
265
286
|
this.log.info(`Assigning session trackingId "${trackingId}"`);
|
|
266
287
|
}
|
|
267
288
|
const decodedLaunchOptions = convertIfBase64(req.parsed.searchParams.get('launch') || '{}');
|
package/build/http.d.ts
CHANGED
|
@@ -151,6 +151,7 @@ export declare enum HTTPRoutes {
|
|
|
151
151
|
export declare enum HTTPManagementRoutes {
|
|
152
152
|
active = "/active?(/)",
|
|
153
153
|
config = "/config?(/)",
|
|
154
|
+
kill = "/kill/+([0-9a-zA-Z-_])?(/)",
|
|
154
155
|
meta = "/meta?(/)",
|
|
155
156
|
metrics = "/metrics?(/)",
|
|
156
157
|
metricsTotal = "/metrics/total?(/)",
|
|
@@ -192,4 +193,8 @@ export interface SystemQueryParameters {
|
|
|
192
193
|
* The authorization token
|
|
193
194
|
*/
|
|
194
195
|
token?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Custom session identifier
|
|
198
|
+
*/
|
|
199
|
+
trackingId?: string;
|
|
195
200
|
}
|
package/build/http.js
CHANGED
|
@@ -117,6 +117,7 @@ export var HTTPManagementRoutes;
|
|
|
117
117
|
(function (HTTPManagementRoutes) {
|
|
118
118
|
HTTPManagementRoutes["active"] = "/active?(/)";
|
|
119
119
|
HTTPManagementRoutes["config"] = "/config?(/)";
|
|
120
|
+
HTTPManagementRoutes["kill"] = "/kill/+([0-9a-zA-Z-_])?(/)";
|
|
120
121
|
HTTPManagementRoutes["meta"] = "/meta?(/)";
|
|
121
122
|
HTTPManagementRoutes["metrics"] = "/metrics?(/)";
|
|
122
123
|
HTTPManagementRoutes["metricsTotal"] = "/metrics/total?(/)";
|
|
@@ -463,14 +463,14 @@
|
|
|
463
463
|
"length": {
|
|
464
464
|
"type": "number"
|
|
465
465
|
},
|
|
466
|
-
"__@toStringTag@
|
|
466
|
+
"__@toStringTag@72431": {
|
|
467
467
|
"type": "string",
|
|
468
468
|
"const": "Uint8Array"
|
|
469
469
|
}
|
|
470
470
|
},
|
|
471
471
|
"required": [
|
|
472
472
|
"BYTES_PER_ELEMENT",
|
|
473
|
-
"__@toStringTag@
|
|
473
|
+
"__@toStringTag@72431",
|
|
474
474
|
"buffer",
|
|
475
475
|
"byteLength",
|
|
476
476
|
"byteOffset",
|
|
@@ -505,13 +505,13 @@
|
|
|
505
505
|
"byteLength": {
|
|
506
506
|
"type": "number"
|
|
507
507
|
},
|
|
508
|
-
"__@toStringTag@
|
|
508
|
+
"__@toStringTag@72431": {
|
|
509
509
|
"type": "string"
|
|
510
510
|
}
|
|
511
511
|
},
|
|
512
512
|
"additionalProperties": false,
|
|
513
513
|
"required": [
|
|
514
|
-
"__@toStringTag@
|
|
514
|
+
"__@toStringTag@72431",
|
|
515
515
|
"byteLength"
|
|
516
516
|
]
|
|
517
517
|
},
|
|
@@ -521,18 +521,18 @@
|
|
|
521
521
|
"byteLength": {
|
|
522
522
|
"type": "number"
|
|
523
523
|
},
|
|
524
|
-
"__@species@
|
|
524
|
+
"__@species@72469": {
|
|
525
525
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
526
526
|
},
|
|
527
|
-
"__@toStringTag@
|
|
527
|
+
"__@toStringTag@72431": {
|
|
528
528
|
"type": "string",
|
|
529
529
|
"const": "SharedArrayBuffer"
|
|
530
530
|
}
|
|
531
531
|
},
|
|
532
532
|
"additionalProperties": false,
|
|
533
533
|
"required": [
|
|
534
|
-
"__@species@
|
|
535
|
-
"__@toStringTag@
|
|
534
|
+
"__@species@72469",
|
|
535
|
+
"__@toStringTag@72431",
|
|
536
536
|
"byteLength"
|
|
537
537
|
]
|
|
538
538
|
},
|
|
@@ -608,14 +608,14 @@
|
|
|
608
608
|
"length": {
|
|
609
609
|
"type": "number"
|
|
610
610
|
},
|
|
611
|
-
"__@toStringTag@
|
|
611
|
+
"__@toStringTag@116375": {
|
|
612
612
|
"type": "string",
|
|
613
613
|
"const": "Uint8Array"
|
|
614
614
|
}
|
|
615
615
|
},
|
|
616
616
|
"required": [
|
|
617
617
|
"BYTES_PER_ELEMENT",
|
|
618
|
-
"__@toStringTag@
|
|
618
|
+
"__@toStringTag@116375",
|
|
619
619
|
"buffer",
|
|
620
620
|
"byteLength",
|
|
621
621
|
"byteOffset",
|
|
@@ -650,13 +650,13 @@
|
|
|
650
650
|
"byteLength": {
|
|
651
651
|
"type": "number"
|
|
652
652
|
},
|
|
653
|
-
"__@toStringTag@
|
|
653
|
+
"__@toStringTag@116375": {
|
|
654
654
|
"type": "string"
|
|
655
655
|
}
|
|
656
656
|
},
|
|
657
657
|
"additionalProperties": false,
|
|
658
658
|
"required": [
|
|
659
|
-
"__@toStringTag@
|
|
659
|
+
"__@toStringTag@116375",
|
|
660
660
|
"byteLength"
|
|
661
661
|
]
|
|
662
662
|
},
|
|
@@ -666,18 +666,18 @@
|
|
|
666
666
|
"byteLength": {
|
|
667
667
|
"type": "number"
|
|
668
668
|
},
|
|
669
|
-
"__@species@
|
|
669
|
+
"__@species@116413": {
|
|
670
670
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
671
671
|
},
|
|
672
|
-
"__@toStringTag@
|
|
672
|
+
"__@toStringTag@116375": {
|
|
673
673
|
"type": "string",
|
|
674
674
|
"const": "SharedArrayBuffer"
|
|
675
675
|
}
|
|
676
676
|
},
|
|
677
677
|
"additionalProperties": false,
|
|
678
678
|
"required": [
|
|
679
|
-
"__@species@
|
|
680
|
-
"__@toStringTag@
|
|
679
|
+
"__@species@116413",
|
|
680
|
+
"__@toStringTag@116375",
|
|
681
681
|
"byteLength"
|
|
682
682
|
]
|
|
683
683
|
},
|
|
@@ -510,14 +510,14 @@
|
|
|
510
510
|
"length": {
|
|
511
511
|
"type": "number"
|
|
512
512
|
},
|
|
513
|
-
"__@toStringTag@
|
|
513
|
+
"__@toStringTag@101613": {
|
|
514
514
|
"type": "string",
|
|
515
515
|
"const": "Uint8Array"
|
|
516
516
|
}
|
|
517
517
|
},
|
|
518
518
|
"required": [
|
|
519
519
|
"BYTES_PER_ELEMENT",
|
|
520
|
-
"__@toStringTag@
|
|
520
|
+
"__@toStringTag@101613",
|
|
521
521
|
"buffer",
|
|
522
522
|
"byteLength",
|
|
523
523
|
"byteOffset",
|
|
@@ -552,13 +552,13 @@
|
|
|
552
552
|
"byteLength": {
|
|
553
553
|
"type": "number"
|
|
554
554
|
},
|
|
555
|
-
"__@toStringTag@
|
|
555
|
+
"__@toStringTag@101613": {
|
|
556
556
|
"type": "string"
|
|
557
557
|
}
|
|
558
558
|
},
|
|
559
559
|
"additionalProperties": false,
|
|
560
560
|
"required": [
|
|
561
|
-
"__@toStringTag@
|
|
561
|
+
"__@toStringTag@101613",
|
|
562
562
|
"byteLength"
|
|
563
563
|
]
|
|
564
564
|
},
|
|
@@ -568,18 +568,18 @@
|
|
|
568
568
|
"byteLength": {
|
|
569
569
|
"type": "number"
|
|
570
570
|
},
|
|
571
|
-
"__@species@
|
|
571
|
+
"__@species@101651": {
|
|
572
572
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
573
573
|
},
|
|
574
|
-
"__@toStringTag@
|
|
574
|
+
"__@toStringTag@101613": {
|
|
575
575
|
"type": "string",
|
|
576
576
|
"const": "SharedArrayBuffer"
|
|
577
577
|
}
|
|
578
578
|
},
|
|
579
579
|
"additionalProperties": false,
|
|
580
580
|
"required": [
|
|
581
|
-
"__@species@
|
|
582
|
-
"__@toStringTag@
|
|
581
|
+
"__@species@101651",
|
|
582
|
+
"__@toStringTag@101613",
|
|
583
583
|
"byteLength"
|
|
584
584
|
]
|
|
585
585
|
},
|
|
@@ -553,14 +553,14 @@
|
|
|
553
553
|
"length": {
|
|
554
554
|
"type": "number"
|
|
555
555
|
},
|
|
556
|
-
"__@toStringTag@
|
|
556
|
+
"__@toStringTag@160057": {
|
|
557
557
|
"type": "string",
|
|
558
558
|
"const": "Uint8Array"
|
|
559
559
|
}
|
|
560
560
|
},
|
|
561
561
|
"required": [
|
|
562
562
|
"BYTES_PER_ELEMENT",
|
|
563
|
-
"__@toStringTag@
|
|
563
|
+
"__@toStringTag@160057",
|
|
564
564
|
"buffer",
|
|
565
565
|
"byteLength",
|
|
566
566
|
"byteOffset",
|
|
@@ -595,13 +595,13 @@
|
|
|
595
595
|
"byteLength": {
|
|
596
596
|
"type": "number"
|
|
597
597
|
},
|
|
598
|
-
"__@toStringTag@
|
|
598
|
+
"__@toStringTag@160057": {
|
|
599
599
|
"type": "string"
|
|
600
600
|
}
|
|
601
601
|
},
|
|
602
602
|
"additionalProperties": false,
|
|
603
603
|
"required": [
|
|
604
|
-
"__@toStringTag@
|
|
604
|
+
"__@toStringTag@160057",
|
|
605
605
|
"byteLength"
|
|
606
606
|
]
|
|
607
607
|
},
|
|
@@ -611,18 +611,18 @@
|
|
|
611
611
|
"byteLength": {
|
|
612
612
|
"type": "number"
|
|
613
613
|
},
|
|
614
|
-
"__@species@
|
|
614
|
+
"__@species@160095": {
|
|
615
615
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
616
616
|
},
|
|
617
|
-
"__@toStringTag@
|
|
617
|
+
"__@toStringTag@160057": {
|
|
618
618
|
"type": "string",
|
|
619
619
|
"const": "SharedArrayBuffer"
|
|
620
620
|
}
|
|
621
621
|
},
|
|
622
622
|
"additionalProperties": false,
|
|
623
623
|
"required": [
|
|
624
|
-
"__@species@
|
|
625
|
-
"__@toStringTag@
|
|
624
|
+
"__@species@160095",
|
|
625
|
+
"__@toStringTag@160057",
|
|
626
626
|
"byteLength"
|
|
627
627
|
]
|
|
628
628
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Browserless, Config, Metrics } from '@browserless.io/browserless';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import puppeteer from 'puppeteer-core';
|
|
4
|
+
describe('/kill API', function () {
|
|
5
|
+
let browserless;
|
|
6
|
+
const start = ({ config = new Config(), metrics = new Metrics(), } = {}) => {
|
|
7
|
+
config.setToken('6R0W53R135510');
|
|
8
|
+
browserless = new Browserless({ config, metrics });
|
|
9
|
+
return browserless.start();
|
|
10
|
+
};
|
|
11
|
+
afterEach(async () => {
|
|
12
|
+
await browserless.stop();
|
|
13
|
+
});
|
|
14
|
+
it('Kill all sessions', async () => {
|
|
15
|
+
await start();
|
|
16
|
+
const browser1 = await puppeteer.connect({
|
|
17
|
+
browserWSEndpoint: `ws://localhost:3000/chrome?token=6R0W53R135510`,
|
|
18
|
+
});
|
|
19
|
+
const browser2 = await puppeteer.connect({
|
|
20
|
+
browserWSEndpoint: `ws://localhost:3000/chrome?token=6R0W53R135510`,
|
|
21
|
+
});
|
|
22
|
+
await fetch('http://localhost:3000/kill/all?token=6R0W53R135510').then(async (res) => {
|
|
23
|
+
expect(res.status).to.equal(204);
|
|
24
|
+
});
|
|
25
|
+
let errorThrown1;
|
|
26
|
+
try {
|
|
27
|
+
await browser1.newPage();
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
errorThrown1 = e;
|
|
31
|
+
}
|
|
32
|
+
let errorThrown2;
|
|
33
|
+
try {
|
|
34
|
+
await browser2.newPage();
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
errorThrown2 = e;
|
|
38
|
+
}
|
|
39
|
+
expect(errorThrown1.message).contains('closed');
|
|
40
|
+
expect(errorThrown2.message).contains('closed');
|
|
41
|
+
});
|
|
42
|
+
it('Kill session by browserId', async () => {
|
|
43
|
+
await start();
|
|
44
|
+
const browser = await puppeteer.connect({
|
|
45
|
+
browserWSEndpoint: `ws://localhost:3000/chrome?token=6R0W53R135510`,
|
|
46
|
+
});
|
|
47
|
+
await fetch('http://localhost:3000/sessions?token=6R0W53R135510').then(async (res) => {
|
|
48
|
+
const sessions = await res.json();
|
|
49
|
+
const browserId = sessions[0].browserId;
|
|
50
|
+
await fetch(`http://localhost:3000/kill/${browserId}?token=6R0W53R135510`).then(async (res) => {
|
|
51
|
+
expect(res.status).to.equal(204);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
let errorThrown;
|
|
55
|
+
try {
|
|
56
|
+
await browser.newPage();
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
errorThrown = e;
|
|
60
|
+
}
|
|
61
|
+
expect(errorThrown.message).contains('closed');
|
|
62
|
+
});
|
|
63
|
+
it('Kill session by trackingId', async () => {
|
|
64
|
+
await start();
|
|
65
|
+
const browser = await puppeteer.connect({
|
|
66
|
+
browserWSEndpoint: `ws://localhost:3000/chrome?token=6R0W53R135510&trackingId=session-1`,
|
|
67
|
+
});
|
|
68
|
+
await fetch('http://localhost:3000/kill/session-1?token=6R0W53R135510').then(async (res) => {
|
|
69
|
+
expect(res.status).to.equal(204);
|
|
70
|
+
});
|
|
71
|
+
let errorThrown;
|
|
72
|
+
try {
|
|
73
|
+
await browser.newPage();
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
errorThrown = e;
|
|
77
|
+
}
|
|
78
|
+
expect(errorThrown.message).contains('closed');
|
|
79
|
+
});
|
|
80
|
+
});
|