@sockethub/server 5.0.0-beta.1 → 5.0.0-beta.3
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/dist/connection-scope.d.ts +1 -0
- package/dist/index.js +166 -57
- package/dist/platform-instance.d.ts +4 -1
- package/dist/platform.js +38 -7
- package/dist/process-manager.d.ts +11 -0
- package/package.json +20 -16
- package/res/sockethub-client.js +15 -15
package/dist/platform.js
CHANGED
|
@@ -20497,7 +20497,7 @@ var init_package = __esm(() => {
|
|
|
20497
20497
|
package_default = {
|
|
20498
20498
|
name: "@sockethub/schemas",
|
|
20499
20499
|
description: "JSON schema files for validating Sockethub Activity Streams",
|
|
20500
|
-
version: "3.0.0-beta.
|
|
20500
|
+
version: "3.0.0-beta.3",
|
|
20501
20501
|
type: "module",
|
|
20502
20502
|
private: false,
|
|
20503
20503
|
author: "Nick Jennings <nick@silverbucket.net>",
|
|
@@ -20567,7 +20567,7 @@ var init_package = __esm(() => {
|
|
|
20567
20567
|
"ajv-formats": "^2.1.1",
|
|
20568
20568
|
"ajv-formats-draft2019": "^1.6.1"
|
|
20569
20569
|
},
|
|
20570
|
-
gitHead: "
|
|
20570
|
+
gitHead: "bc04522d60d1e2fa1b3098b339897de62c3b0549",
|
|
20571
20571
|
types: "./dist/index.d.ts"
|
|
20572
20572
|
};
|
|
20573
20573
|
});
|
|
@@ -20676,8 +20676,12 @@ var init_sockethub_config = __esm(() => {
|
|
|
20676
20676
|
"@sockethub/platform-caldav",
|
|
20677
20677
|
"@sockethub/platform-dummy",
|
|
20678
20678
|
"@sockethub/platform-feeds",
|
|
20679
|
+
"@sockethub/platform-email",
|
|
20679
20680
|
"@sockethub/platform-irc",
|
|
20680
20681
|
"@sockethub/platform-metadata",
|
|
20682
|
+
"@sockethub/platform-messenger",
|
|
20683
|
+
"@sockethub/platform-instagram",
|
|
20684
|
+
"@sockethub/platform-whatsapp",
|
|
20681
20685
|
"@sockethub/platform-xmpp"
|
|
20682
20686
|
]
|
|
20683
20687
|
},
|
|
@@ -20693,7 +20697,8 @@ var init_sockethub_config = __esm(() => {
|
|
|
20693
20697
|
connectTimeoutMs: { type: "integer", minimum: 1 },
|
|
20694
20698
|
allowPrivateAddresses: { type: "boolean" },
|
|
20695
20699
|
allowInsecureHttp: { type: "boolean" },
|
|
20696
|
-
concurrency: { type: "integer", minimum: 1 }
|
|
20700
|
+
concurrency: { type: "integer", minimum: 1 },
|
|
20701
|
+
discoveryCacheTtlMs: { type: "integer", minimum: 0 }
|
|
20697
20702
|
}
|
|
20698
20703
|
},
|
|
20699
20704
|
"@sockethub/platform-caldav": {
|
|
@@ -20703,7 +20708,20 @@ var init_sockethub_config = __esm(() => {
|
|
|
20703
20708
|
connectTimeoutMs: { type: "integer", minimum: 1 },
|
|
20704
20709
|
allowPrivateAddresses: { type: "boolean" },
|
|
20705
20710
|
allowInsecureHttp: { type: "boolean" },
|
|
20706
|
-
concurrency: { type: "integer", minimum: 1 }
|
|
20711
|
+
concurrency: { type: "integer", minimum: 1 },
|
|
20712
|
+
discoveryCacheTtlMs: { type: "integer", minimum: 0 }
|
|
20713
|
+
}
|
|
20714
|
+
},
|
|
20715
|
+
"@sockethub/platform-email": {
|
|
20716
|
+
type: "object",
|
|
20717
|
+
additionalProperties: false,
|
|
20718
|
+
properties: {
|
|
20719
|
+
connectTimeoutMs: {
|
|
20720
|
+
type: "integer",
|
|
20721
|
+
minimum: 5000,
|
|
20722
|
+
maximum: 120000
|
|
20723
|
+
},
|
|
20724
|
+
allowPrivateAddresses: { type: "boolean" }
|
|
20707
20725
|
}
|
|
20708
20726
|
},
|
|
20709
20727
|
"@sockethub/platform-dummy": {
|
|
@@ -20726,7 +20744,8 @@ var init_sockethub_config = __esm(() => {
|
|
|
20726
20744
|
type: "object",
|
|
20727
20745
|
additionalProperties: false,
|
|
20728
20746
|
properties: {
|
|
20729
|
-
connectTimeoutMs: { type: "number" }
|
|
20747
|
+
connectTimeoutMs: { type: "number" },
|
|
20748
|
+
allowPrivateAddresses: { type: "boolean" }
|
|
20730
20749
|
}
|
|
20731
20750
|
},
|
|
20732
20751
|
"@sockethub/platform-xmpp": {
|
|
@@ -20836,6 +20855,12 @@ var init_sockethub_config = __esm(() => {
|
|
|
20836
20855
|
default: 20,
|
|
20837
20856
|
description: "Maximum persistent instances per client IP, including HTTP actions. 0 disables the cap."
|
|
20838
20857
|
},
|
|
20858
|
+
maxStartsPerIpPerMinute: {
|
|
20859
|
+
type: "integer",
|
|
20860
|
+
minimum: 0,
|
|
20861
|
+
default: 60,
|
|
20862
|
+
description: "Maximum new persistent instances a client IP may start per minute, " + "including HTTP actions. Bounds fork/teardown churn that the " + "concurrent caps allow. Reusing a running instance does not count. " + "0 disables the cap."
|
|
20863
|
+
},
|
|
20839
20864
|
maxPlatformInstances: {
|
|
20840
20865
|
type: "number",
|
|
20841
20866
|
minimum: 0,
|
|
@@ -73932,6 +73957,7 @@ var init_config_schema = __esm(() => {
|
|
|
73932
73957
|
"rateLimiter.maxConnectionsPerIp": { format: "nat" },
|
|
73933
73958
|
"limits.maxInstancesPerSession": { format: "nat" },
|
|
73934
73959
|
"limits.maxInstancesPerIp": { format: "nat" },
|
|
73960
|
+
"limits.maxStartsPerIpPerMinute": { format: "nat" },
|
|
73935
73961
|
"limits.maxPlatformInstances": { format: "nat" },
|
|
73936
73962
|
"credentials.ttlMs": {
|
|
73937
73963
|
format: "nat",
|
|
@@ -95752,6 +95778,7 @@ class JobWorker extends JobBase {
|
|
|
95752
95778
|
redisConfig;
|
|
95753
95779
|
queueId;
|
|
95754
95780
|
concurrency;
|
|
95781
|
+
maxStalledCount;
|
|
95755
95782
|
initialized = false;
|
|
95756
95783
|
constructor(parentId, instanceId, secret, redisConfig, options = {}) {
|
|
95757
95784
|
super(secret);
|
|
@@ -95760,6 +95787,7 @@ class JobWorker extends JobBase {
|
|
|
95760
95787
|
throw new Error(`JobWorker concurrency must be a positive integer, got ${options.concurrency}`);
|
|
95761
95788
|
}
|
|
95762
95789
|
this.concurrency = concurrency;
|
|
95790
|
+
this.maxStalledCount = options.maxStalledCount ?? 3;
|
|
95763
95791
|
this.log = createLogger(`data-layer:worker:${parentId}:${instanceId}`);
|
|
95764
95792
|
this.connectionName = getLoggerNamespace(this.log);
|
|
95765
95793
|
redisConfig.connectionName = this.connectionName;
|
|
@@ -95775,7 +95803,7 @@ class JobWorker extends JobBase {
|
|
|
95775
95803
|
this.worker = new import_bullmq2.Worker(queueName, this.jobHandler.bind(this), {
|
|
95776
95804
|
connection: this.redisConfig,
|
|
95777
95805
|
concurrency: this.concurrency,
|
|
95778
|
-
maxStalledCount:
|
|
95806
|
+
maxStalledCount: this.maxStalledCount
|
|
95779
95807
|
});
|
|
95780
95808
|
this.worker.on("error", (err) => {
|
|
95781
95809
|
this.log.warn(`worker error: ${err.message}`);
|
|
@@ -96216,7 +96244,10 @@ async function startPlatformProcess() {
|
|
|
96216
96244
|
}
|
|
96217
96245
|
}
|
|
96218
96246
|
const concurrency = getWorkerConcurrency();
|
|
96219
|
-
jobWorker = new JobWorker(parentId, queueInstanceId, parentSecret1 + parentSecret2, { url: redisUrl }, {
|
|
96247
|
+
jobWorker = new JobWorker(parentId, queueInstanceId, parentSecret1 + parentSecret2, { url: redisUrl }, {
|
|
96248
|
+
concurrency,
|
|
96249
|
+
maxStalledCount: platform.config.persist && platform.config.retryStalledJobs === false ? 0 : 3
|
|
96250
|
+
});
|
|
96220
96251
|
logger.info(`listening on the queue for incoming jobs (concurrency: ${concurrency})`);
|
|
96221
96252
|
jobWorker.onJob(getJobHandler());
|
|
96222
96253
|
jobWorkerStarted = true;
|
|
@@ -6,6 +6,8 @@ declare class ProcessManager {
|
|
|
6
6
|
private readonly parentSecret2;
|
|
7
7
|
private init;
|
|
8
8
|
private readonly ensureChains;
|
|
9
|
+
private readonly startsPerIp;
|
|
10
|
+
private startsWindowBegan;
|
|
9
11
|
constructor(parentId: string, parentSecret1: string, parentSecret2: string, init: IInitObject);
|
|
10
12
|
/**
|
|
11
13
|
* @param sessionId socket id to register with the instance; absent for HTTP
|
|
@@ -28,6 +30,15 @@ declare class ProcessManager {
|
|
|
28
30
|
* of client occupancy. Check owners even when attaching to a shared worker.
|
|
29
31
|
*/
|
|
30
32
|
private assertInstanceCapacity;
|
|
33
|
+
/**
|
|
34
|
+
* Instance caps bound how many workers run at once, not how fast a client
|
|
35
|
+
* can churn them (e.g. replacing credentials forks a fresh worker each
|
|
36
|
+
* time). Budget new persistent starts per IP, the one key a client cannot
|
|
37
|
+
* rotate.
|
|
38
|
+
* shortcut: fixed one-minute window allows a 2x burst at the boundary;
|
|
39
|
+
* switch to a sliding window if that burst matters.
|
|
40
|
+
*/
|
|
41
|
+
private assertStartRate;
|
|
31
42
|
private isProcessAlive;
|
|
32
43
|
}
|
|
33
44
|
export default ProcessManager;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sockethub/server",
|
|
3
3
|
"description": "A polyglot messaging service, server libraries",
|
|
4
|
-
"version": "5.0.0-beta.
|
|
4
|
+
"version": "5.0.0-beta.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"author": "Nick Jennings <nick@silverbucket.net>",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"bin": "bin/sockethub",
|
|
27
27
|
"preferGlobal": true,
|
|
28
28
|
"engines": {
|
|
29
|
-
"node": ">=20"
|
|
29
|
+
"node": ">=20.19"
|
|
30
30
|
},
|
|
31
31
|
"keywords": [
|
|
32
32
|
"sockethub",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@sentry/node": "^10.36.0",
|
|
55
55
|
"@sentry/profiling-node": "10.36.0",
|
|
56
|
-
"@sockethub/client": "^5.0.0-beta.
|
|
57
|
-
"@sockethub/data-layer": "^1.0.0-beta.
|
|
58
|
-
"@sockethub/logger": "^1.0.0-beta.
|
|
59
|
-
"@sockethub/schemas": "^3.0.0-beta.
|
|
60
|
-
"@sockethub/util": "^1.0.0-beta.
|
|
56
|
+
"@sockethub/client": "^5.0.0-beta.3",
|
|
57
|
+
"@sockethub/data-layer": "^1.0.0-beta.3",
|
|
58
|
+
"@sockethub/logger": "^1.0.0-beta.3",
|
|
59
|
+
"@sockethub/schemas": "^3.0.0-beta.3",
|
|
60
|
+
"@sockethub/util": "^1.0.0-beta.3",
|
|
61
61
|
"chalk": "^5.6.2",
|
|
62
62
|
"convict": "^6.2.5",
|
|
63
63
|
"debug": "^4.4.3",
|
|
@@ -91,15 +91,19 @@
|
|
|
91
91
|
"web-streams-polyfill": "^3.3.3"
|
|
92
92
|
},
|
|
93
93
|
"optionalDependencies": {
|
|
94
|
-
"@sockethub/examples": "^1.0.0-beta.
|
|
95
|
-
"@sockethub/platform-caldav": "^1.0.0-beta.
|
|
96
|
-
"@sockethub/platform-carddav": "^1.0.0-beta.
|
|
97
|
-
"@sockethub/platform-dummy": "^3.0.0-beta.
|
|
98
|
-
"@sockethub/platform-
|
|
99
|
-
"@sockethub/platform-
|
|
100
|
-
"@sockethub/platform-
|
|
101
|
-
"@sockethub/platform-
|
|
94
|
+
"@sockethub/examples": "^1.0.0-beta.3",
|
|
95
|
+
"@sockethub/platform-caldav": "^1.0.0-beta.3",
|
|
96
|
+
"@sockethub/platform-carddav": "^1.0.0-beta.3",
|
|
97
|
+
"@sockethub/platform-dummy": "^3.0.0-beta.3",
|
|
98
|
+
"@sockethub/platform-email": "^1.0.0-beta.3",
|
|
99
|
+
"@sockethub/platform-feeds": "^4.0.0-beta.3",
|
|
100
|
+
"@sockethub/platform-instagram": "^1.0.0-beta.3",
|
|
101
|
+
"@sockethub/platform-irc": "^4.0.0-beta.3",
|
|
102
|
+
"@sockethub/platform-messenger": "^1.0.0-beta.3",
|
|
103
|
+
"@sockethub/platform-metadata": "^1.0.1-beta.3",
|
|
104
|
+
"@sockethub/platform-whatsapp": "^1.0.0-beta.3",
|
|
105
|
+
"@sockethub/platform-xmpp": "^5.0.0-beta.3"
|
|
102
106
|
},
|
|
103
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "603d4edd90e1f0f0b70c4ab759be5f70b24020ea",
|
|
104
108
|
"types": "./dist/index.d.ts"
|
|
105
109
|
}
|