@browserless.io/browserless 2.10.0 → 2.11.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/CHANGELOG.md +6 -1
- package/build/browsers/chromium.cdp.d.ts +1 -0
- package/build/browsers/chromium.cdp.js +3 -0
- package/build/browsers/chromium.playwright.d.ts +1 -0
- package/build/browsers/chromium.playwright.js +3 -0
- package/build/browsers/firefox.playwright.d.ts +1 -0
- package/build/browsers/firefox.playwright.js +3 -0
- package/build/browsers/index.d.ts +0 -1
- package/build/browsers/index.js +3 -5
- package/build/browsers/webkit.playwright.d.ts +1 -0
- package/build/browsers/webkit.playwright.js +3 -0
- package/build/routes/chrome/http/pdf.post.body.json +8 -8
- package/build/routes/chrome/http/scrape.post.body.json +8 -8
- package/build/routes/chrome/http/screenshot.post.body.json +8 -8
- package/build/routes/chromium/http/content.post.body.json +8 -8
- package/build/routes/chromium/http/pdf.post.body.json +8 -8
- package/build/routes/chromium/http/scrape.post.body.json +8 -8
- package/build/routes/management/http/pressure.get.d.ts +47 -45
- package/build/routes/management/http/pressure.get.js +13 -11
- package/build/routes/management/http/pressure.get.response.json +74 -65
- package/package.json +1 -1
- package/src/browsers/chromium.cdp.ts +4 -0
- package/src/browsers/chromium.playwright.ts +4 -0
- package/src/browsers/firefox.playwright.ts +4 -0
- package/src/browsers/index.ts +3 -5
- package/src/browsers/webkit.playwright.ts +4 -0
- package/src/routes/management/http/pressure.get.ts +70 -66
- package/static/docs/swagger.json +76 -67
- package/static/docs/swagger.min.json +75 -66
|
@@ -1,76 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "object",
|
|
3
3
|
"properties": {
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
""
|
|
4
|
+
"pressure": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"cpu": {
|
|
8
|
+
"description": "An integer representing the percentage of CPU being used. For instance 92 means 92%",
|
|
9
|
+
"type": [
|
|
10
|
+
"null",
|
|
11
|
+
"number"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"date": {
|
|
15
|
+
"description": "A number of milliseconds since epoch, or \"Date.now()\" equivalent.",
|
|
16
|
+
"type": "number"
|
|
17
|
+
},
|
|
18
|
+
"isAvailable": {
|
|
19
|
+
"description": "Whether or not a session can be connected and immediately ran on a health instance.",
|
|
20
|
+
"type": "boolean"
|
|
21
|
+
},
|
|
22
|
+
"maxConcurrent": {
|
|
23
|
+
"description": "The maximum amount of browsers that can be ran at a single time.",
|
|
24
|
+
"type": "number"
|
|
25
|
+
},
|
|
26
|
+
"maxQueued": {
|
|
27
|
+
"description": "The maximum amount of queued connections allowed at a single time.",
|
|
28
|
+
"type": "number"
|
|
29
|
+
},
|
|
30
|
+
"memory": {
|
|
31
|
+
"description": "An integer representing the percentage of Memory being used. For instance 95 means 95%",
|
|
32
|
+
"type": [
|
|
33
|
+
"null",
|
|
34
|
+
"number"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"message": {
|
|
38
|
+
"description": "A human-readable message as the overall status of the instance.",
|
|
39
|
+
"type": "string"
|
|
40
|
+
},
|
|
41
|
+
"queued": {
|
|
42
|
+
"description": "The current number of connect or API calls pending to run.",
|
|
43
|
+
"type": "number"
|
|
44
|
+
},
|
|
45
|
+
"reason": {
|
|
46
|
+
"description": "A simple single-word reason as to why an instance may or may not be available.",
|
|
47
|
+
"enum": [
|
|
48
|
+
"",
|
|
49
|
+
"cpu",
|
|
50
|
+
"full",
|
|
51
|
+
"memory"
|
|
52
|
+
],
|
|
53
|
+
"type": "string"
|
|
54
|
+
},
|
|
55
|
+
"recentlyRejected": {
|
|
56
|
+
"description": "The number of recent connections that were rejected due to the queue and concurrency\nlimits having been filled.",
|
|
57
|
+
"type": "number"
|
|
58
|
+
},
|
|
59
|
+
"running": {
|
|
60
|
+
"description": "The current number of running connections or API calls.",
|
|
61
|
+
"type": "number"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"additionalProperties": false,
|
|
65
|
+
"required": [
|
|
46
66
|
"cpu",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"type": "number"
|
|
67
|
+
"date",
|
|
68
|
+
"isAvailable",
|
|
69
|
+
"maxConcurrent",
|
|
70
|
+
"maxQueued",
|
|
71
|
+
"memory",
|
|
72
|
+
"message",
|
|
73
|
+
"queued",
|
|
74
|
+
"reason",
|
|
75
|
+
"recentlyRejected",
|
|
76
|
+
"running"
|
|
77
|
+
]
|
|
59
78
|
}
|
|
60
79
|
},
|
|
61
80
|
"additionalProperties": false,
|
|
62
81
|
"required": [
|
|
63
|
-
"
|
|
64
|
-
"date",
|
|
65
|
-
"isAvailable",
|
|
66
|
-
"maxConcurrent",
|
|
67
|
-
"maxQueued",
|
|
68
|
-
"memory",
|
|
69
|
-
"message",
|
|
70
|
-
"queued",
|
|
71
|
-
"reason",
|
|
72
|
-
"recentlyRejected",
|
|
73
|
-
"running"
|
|
82
|
+
"pressure"
|
|
74
83
|
],
|
|
75
84
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
76
85
|
}
|
package/package.json
CHANGED
package/src/browsers/index.ts
CHANGED
|
@@ -36,7 +36,6 @@ import path from 'path';
|
|
|
36
36
|
|
|
37
37
|
export class BrowserManager {
|
|
38
38
|
protected browsers: Map<BrowserInstance, BrowserlessSession> = new Map();
|
|
39
|
-
protected launching: Map<string, Promise<unknown>> = new Map();
|
|
40
39
|
protected timers: Map<string, number> = new Map();
|
|
41
40
|
protected log = new Logger('browser-manager');
|
|
42
41
|
protected chromeBrowsers = [ChromiumCDP, ChromeCDP];
|
|
@@ -272,7 +271,7 @@ export class BrowserManager {
|
|
|
272
271
|
this.log.info(`${session.numbConnected} Client(s) are currently connected`);
|
|
273
272
|
|
|
274
273
|
// Don't close if there's clients still connected
|
|
275
|
-
if (session.numbConnected > 0) {
|
|
274
|
+
if (session.numbConnected > 0 || browser.keepAlive()) {
|
|
276
275
|
return;
|
|
277
276
|
}
|
|
278
277
|
|
|
@@ -314,7 +313,6 @@ export class BrowserManager {
|
|
|
314
313
|
|
|
315
314
|
if (id && resolver) {
|
|
316
315
|
resolver(null);
|
|
317
|
-
this.launching.delete(id);
|
|
318
316
|
}
|
|
319
317
|
|
|
320
318
|
--session.numbConnected;
|
|
@@ -457,7 +455,7 @@ export class BrowserManager {
|
|
|
457
455
|
userDataDir,
|
|
458
456
|
});
|
|
459
457
|
|
|
460
|
-
const
|
|
458
|
+
const session: BrowserlessSession = {
|
|
461
459
|
id: null,
|
|
462
460
|
initialConnectURL:
|
|
463
461
|
path.join(req.parsed.pathname, req.parsed.search) || '',
|
|
@@ -471,7 +469,7 @@ export class BrowserManager {
|
|
|
471
469
|
userDataDir,
|
|
472
470
|
};
|
|
473
471
|
|
|
474
|
-
this.browsers.set(browser,
|
|
472
|
+
this.browsers.set(browser, session);
|
|
475
473
|
|
|
476
474
|
await browser.launch(launchOptions as object);
|
|
477
475
|
await this.hooks.browser({ browser, meta: req.parsed });
|
|
@@ -11,61 +11,63 @@ import {
|
|
|
11
11
|
import { ServerResponse } from 'http';
|
|
12
12
|
|
|
13
13
|
export type ResponseSchema = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
14
|
+
pressure: {
|
|
15
|
+
/**
|
|
16
|
+
* An integer representing the percentage of CPU being used. For instance 92 means 92%
|
|
17
|
+
*/
|
|
18
|
+
cpu: number | null;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A number of milliseconds since epoch, or "Date.now()" equivalent.
|
|
22
|
+
*/
|
|
23
|
+
date: number;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Whether or not a session can be connected and immediately ran on a health instance.
|
|
27
|
+
*/
|
|
28
|
+
isAvailable: boolean;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The maximum amount of browsers that can be ran at a single time.
|
|
32
|
+
*/
|
|
33
|
+
maxConcurrent: number;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The maximum amount of queued connections allowed at a single time.
|
|
37
|
+
*/
|
|
38
|
+
maxQueued: number;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* An integer representing the percentage of Memory being used. For instance 95 means 95%
|
|
42
|
+
*/
|
|
43
|
+
memory: number | null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A human-readable message as the overall status of the instance.
|
|
47
|
+
*/
|
|
48
|
+
message: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The current number of connect or API calls pending to run.
|
|
52
|
+
*/
|
|
53
|
+
queued: number;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A simple single-word reason as to why an instance may or may not be available.
|
|
57
|
+
*/
|
|
58
|
+
reason: 'full' | 'cpu' | 'memory' | '';
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The number of recent connections that were rejected due to the queue and concurrency
|
|
62
|
+
* limits having been filled.
|
|
63
|
+
*/
|
|
64
|
+
recentlyRejected: number;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The current number of running connections or API calls.
|
|
68
|
+
*/
|
|
69
|
+
running: number;
|
|
70
|
+
};
|
|
69
71
|
};
|
|
70
72
|
|
|
71
73
|
export default class PressureGetRoute extends HTTPRoute {
|
|
@@ -117,17 +119,19 @@ export default class PressureGetRoute extends HTTPRoute {
|
|
|
117
119
|
: '';
|
|
118
120
|
|
|
119
121
|
const response: ResponseSchema = {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
pressure: {
|
|
123
|
+
cpu,
|
|
124
|
+
date,
|
|
125
|
+
isAvailable,
|
|
126
|
+
maxConcurrent,
|
|
127
|
+
maxQueued,
|
|
128
|
+
memory,
|
|
129
|
+
message,
|
|
130
|
+
queued,
|
|
131
|
+
reason,
|
|
132
|
+
recentlyRejected,
|
|
133
|
+
running,
|
|
134
|
+
},
|
|
131
135
|
};
|
|
132
136
|
|
|
133
137
|
return jsonResponse(res, 200, response);
|