@sockethub/server 5.0.0-beta.1 → 5.0.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/dist/connection-scope.d.ts +1 -0
- package/dist/index.js +164 -57
- package/dist/platform-instance.d.ts +4 -1
- package/dist/platform.js +37 -7
- package/dist/process-manager.d.ts +11 -0
- package/package.json +19 -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.2",
|
|
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: "1f74d4e07311496f0acc021855137bc197d79eab",
|
|
20571
20571
|
types: "./dist/index.d.ts"
|
|
20572
20572
|
};
|
|
20573
20573
|
});
|
|
@@ -20676,8 +20676,11 @@ 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",
|
|
20681
20684
|
"@sockethub/platform-xmpp"
|
|
20682
20685
|
]
|
|
20683
20686
|
},
|
|
@@ -20693,7 +20696,8 @@ var init_sockethub_config = __esm(() => {
|
|
|
20693
20696
|
connectTimeoutMs: { type: "integer", minimum: 1 },
|
|
20694
20697
|
allowPrivateAddresses: { type: "boolean" },
|
|
20695
20698
|
allowInsecureHttp: { type: "boolean" },
|
|
20696
|
-
concurrency: { type: "integer", minimum: 1 }
|
|
20699
|
+
concurrency: { type: "integer", minimum: 1 },
|
|
20700
|
+
discoveryCacheTtlMs: { type: "integer", minimum: 0 }
|
|
20697
20701
|
}
|
|
20698
20702
|
},
|
|
20699
20703
|
"@sockethub/platform-caldav": {
|
|
@@ -20703,7 +20707,20 @@ var init_sockethub_config = __esm(() => {
|
|
|
20703
20707
|
connectTimeoutMs: { type: "integer", minimum: 1 },
|
|
20704
20708
|
allowPrivateAddresses: { type: "boolean" },
|
|
20705
20709
|
allowInsecureHttp: { type: "boolean" },
|
|
20706
|
-
concurrency: { type: "integer", minimum: 1 }
|
|
20710
|
+
concurrency: { type: "integer", minimum: 1 },
|
|
20711
|
+
discoveryCacheTtlMs: { type: "integer", minimum: 0 }
|
|
20712
|
+
}
|
|
20713
|
+
},
|
|
20714
|
+
"@sockethub/platform-email": {
|
|
20715
|
+
type: "object",
|
|
20716
|
+
additionalProperties: false,
|
|
20717
|
+
properties: {
|
|
20718
|
+
connectTimeoutMs: {
|
|
20719
|
+
type: "integer",
|
|
20720
|
+
minimum: 5000,
|
|
20721
|
+
maximum: 120000
|
|
20722
|
+
},
|
|
20723
|
+
allowPrivateAddresses: { type: "boolean" }
|
|
20707
20724
|
}
|
|
20708
20725
|
},
|
|
20709
20726
|
"@sockethub/platform-dummy": {
|
|
@@ -20726,7 +20743,8 @@ var init_sockethub_config = __esm(() => {
|
|
|
20726
20743
|
type: "object",
|
|
20727
20744
|
additionalProperties: false,
|
|
20728
20745
|
properties: {
|
|
20729
|
-
connectTimeoutMs: { type: "number" }
|
|
20746
|
+
connectTimeoutMs: { type: "number" },
|
|
20747
|
+
allowPrivateAddresses: { type: "boolean" }
|
|
20730
20748
|
}
|
|
20731
20749
|
},
|
|
20732
20750
|
"@sockethub/platform-xmpp": {
|
|
@@ -20836,6 +20854,12 @@ var init_sockethub_config = __esm(() => {
|
|
|
20836
20854
|
default: 20,
|
|
20837
20855
|
description: "Maximum persistent instances per client IP, including HTTP actions. 0 disables the cap."
|
|
20838
20856
|
},
|
|
20857
|
+
maxStartsPerIpPerMinute: {
|
|
20858
|
+
type: "integer",
|
|
20859
|
+
minimum: 0,
|
|
20860
|
+
default: 60,
|
|
20861
|
+
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."
|
|
20862
|
+
},
|
|
20839
20863
|
maxPlatformInstances: {
|
|
20840
20864
|
type: "number",
|
|
20841
20865
|
minimum: 0,
|
|
@@ -73932,6 +73956,7 @@ var init_config_schema = __esm(() => {
|
|
|
73932
73956
|
"rateLimiter.maxConnectionsPerIp": { format: "nat" },
|
|
73933
73957
|
"limits.maxInstancesPerSession": { format: "nat" },
|
|
73934
73958
|
"limits.maxInstancesPerIp": { format: "nat" },
|
|
73959
|
+
"limits.maxStartsPerIpPerMinute": { format: "nat" },
|
|
73935
73960
|
"limits.maxPlatformInstances": { format: "nat" },
|
|
73936
73961
|
"credentials.ttlMs": {
|
|
73937
73962
|
format: "nat",
|
|
@@ -95752,6 +95777,7 @@ class JobWorker extends JobBase {
|
|
|
95752
95777
|
redisConfig;
|
|
95753
95778
|
queueId;
|
|
95754
95779
|
concurrency;
|
|
95780
|
+
maxStalledCount;
|
|
95755
95781
|
initialized = false;
|
|
95756
95782
|
constructor(parentId, instanceId, secret, redisConfig, options = {}) {
|
|
95757
95783
|
super(secret);
|
|
@@ -95760,6 +95786,7 @@ class JobWorker extends JobBase {
|
|
|
95760
95786
|
throw new Error(`JobWorker concurrency must be a positive integer, got ${options.concurrency}`);
|
|
95761
95787
|
}
|
|
95762
95788
|
this.concurrency = concurrency;
|
|
95789
|
+
this.maxStalledCount = options.maxStalledCount ?? 3;
|
|
95763
95790
|
this.log = createLogger(`data-layer:worker:${parentId}:${instanceId}`);
|
|
95764
95791
|
this.connectionName = getLoggerNamespace(this.log);
|
|
95765
95792
|
redisConfig.connectionName = this.connectionName;
|
|
@@ -95775,7 +95802,7 @@ class JobWorker extends JobBase {
|
|
|
95775
95802
|
this.worker = new import_bullmq2.Worker(queueName, this.jobHandler.bind(this), {
|
|
95776
95803
|
connection: this.redisConfig,
|
|
95777
95804
|
concurrency: this.concurrency,
|
|
95778
|
-
maxStalledCount:
|
|
95805
|
+
maxStalledCount: this.maxStalledCount
|
|
95779
95806
|
});
|
|
95780
95807
|
this.worker.on("error", (err) => {
|
|
95781
95808
|
this.log.warn(`worker error: ${err.message}`);
|
|
@@ -96216,7 +96243,10 @@ async function startPlatformProcess() {
|
|
|
96216
96243
|
}
|
|
96217
96244
|
}
|
|
96218
96245
|
const concurrency = getWorkerConcurrency();
|
|
96219
|
-
jobWorker = new JobWorker(parentId, queueInstanceId, parentSecret1 + parentSecret2, { url: redisUrl }, {
|
|
96246
|
+
jobWorker = new JobWorker(parentId, queueInstanceId, parentSecret1 + parentSecret2, { url: redisUrl }, {
|
|
96247
|
+
concurrency,
|
|
96248
|
+
maxStalledCount: platform.config.persist && platform.config.retryStalledJobs === false ? 0 : 3
|
|
96249
|
+
});
|
|
96220
96250
|
logger.info(`listening on the queue for incoming jobs (concurrency: ${concurrency})`);
|
|
96221
96251
|
jobWorker.onJob(getJobHandler());
|
|
96222
96252
|
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.2",
|
|
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.2",
|
|
57
|
+
"@sockethub/data-layer": "^1.0.0-beta.2",
|
|
58
|
+
"@sockethub/logger": "^1.0.0-beta.2",
|
|
59
|
+
"@sockethub/schemas": "^3.0.0-beta.2",
|
|
60
|
+
"@sockethub/util": "^1.0.0-beta.2",
|
|
61
61
|
"chalk": "^5.6.2",
|
|
62
62
|
"convict": "^6.2.5",
|
|
63
63
|
"debug": "^4.4.3",
|
|
@@ -91,15 +91,18 @@
|
|
|
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.2",
|
|
95
|
+
"@sockethub/platform-caldav": "^1.0.0-beta.2",
|
|
96
|
+
"@sockethub/platform-carddav": "^1.0.0-beta.2",
|
|
97
|
+
"@sockethub/platform-dummy": "^3.0.0-beta.2",
|
|
98
|
+
"@sockethub/platform-email": "^1.0.0-beta.2",
|
|
99
|
+
"@sockethub/platform-feeds": "^4.0.0-beta.2",
|
|
100
|
+
"@sockethub/platform-instagram": "^1.0.0-beta.2",
|
|
101
|
+
"@sockethub/platform-irc": "^4.0.0-beta.2",
|
|
102
|
+
"@sockethub/platform-messenger": "^1.0.0-beta.2",
|
|
103
|
+
"@sockethub/platform-metadata": "^1.0.1-beta.2",
|
|
104
|
+
"@sockethub/platform-xmpp": "^5.0.0-beta.2"
|
|
102
105
|
},
|
|
103
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "d241420f9743f66a15ed083a1390595b331a96ac",
|
|
104
107
|
"types": "./dist/index.d.ts"
|
|
105
108
|
}
|