@mblaney/holster 1.0.20 → 1.0.22
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/.dockerignore +9 -0
- package/Dockerfile +20 -0
- package/README.md +15 -3
- package/build/holster.js +1 -1
- package/build/holster.js.map +3 -3
- package/package.json +1 -1
- package/src/wire.js +13 -8
package/package.json
CHANGED
package/src/wire.js
CHANGED
|
@@ -15,7 +15,7 @@ if (typeof globalThis.WebSocket === "undefined") {
|
|
|
15
15
|
// Rate limiting with throttling
|
|
16
16
|
const createRateLimiter = isTestEnv => {
|
|
17
17
|
const clients = new Map()
|
|
18
|
-
const maxRequests =
|
|
18
|
+
const maxRequests = 1500 // requests per minute
|
|
19
19
|
const windowMs = 60000 // 1 minute window
|
|
20
20
|
const disconnectThreshold = 10 // Disconnect after 10 violations
|
|
21
21
|
let cleanupInterval = null
|
|
@@ -267,7 +267,10 @@ const Wire = opt => {
|
|
|
267
267
|
if (Object.keys(update.now).length === 0) {
|
|
268
268
|
// No updates to store, check deferred.
|
|
269
269
|
if (Object.keys(update.defer).length !== 0) {
|
|
270
|
-
setTimeout(
|
|
270
|
+
setTimeout(
|
|
271
|
+
() => put({put: update.defer, "#": msg["#"]}, send),
|
|
272
|
+
update.wait,
|
|
273
|
+
)
|
|
271
274
|
}
|
|
272
275
|
return
|
|
273
276
|
}
|
|
@@ -285,7 +288,10 @@ const Wire = opt => {
|
|
|
285
288
|
})
|
|
286
289
|
|
|
287
290
|
if (Object.keys(update.defer).length !== 0) {
|
|
288
|
-
setTimeout(
|
|
291
|
+
setTimeout(
|
|
292
|
+
() => put({put: update.defer, "#": msg["#"]}, send),
|
|
293
|
+
update.wait,
|
|
294
|
+
)
|
|
289
295
|
}
|
|
290
296
|
}
|
|
291
297
|
|
|
@@ -648,7 +654,7 @@ const Wire = opt => {
|
|
|
648
654
|
// Schedule processing of next message if queue not empty
|
|
649
655
|
if (messageQueue.length > 0) {
|
|
650
656
|
// Add delay between messages to respect rate limit
|
|
651
|
-
queueProcessor = setTimeout(processQueue,
|
|
657
|
+
queueProcessor = setTimeout(processQueue, 50)
|
|
652
658
|
} else {
|
|
653
659
|
queueProcessor = null
|
|
654
660
|
}
|
|
@@ -692,7 +698,7 @@ const Wire = opt => {
|
|
|
692
698
|
messageQueue.push(data)
|
|
693
699
|
// Start queue processor if not already running
|
|
694
700
|
if (!queueProcessor) {
|
|
695
|
-
queueProcessor = setTimeout(processQueue,
|
|
701
|
+
queueProcessor = setTimeout(processQueue, 50)
|
|
696
702
|
}
|
|
697
703
|
}
|
|
698
704
|
if (!(opt.peers instanceof Array)) {
|
|
@@ -768,12 +774,11 @@ const Wire = opt => {
|
|
|
768
774
|
}
|
|
769
775
|
// Store filtered data if any
|
|
770
776
|
if (Object.keys(filteredPut).length > 0) {
|
|
771
|
-
// Create filtered message for Ham.mix
|
|
772
|
-
const filteredMsg = {put: filteredPut}
|
|
777
|
+
// Create filtered message for Ham.mix with original message ID
|
|
778
|
+
const filteredMsg = {put: filteredPut, "#": msg["#"]}
|
|
773
779
|
put(filteredMsg, send)
|
|
774
780
|
}
|
|
775
781
|
}
|
|
776
|
-
send(m.data)
|
|
777
782
|
|
|
778
783
|
const id = msg["@"]
|
|
779
784
|
const cb = queue[id]
|