@mblaney/holster 1.0.18 → 1.0.19
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/build/holster.js +3 -3
- package/build/holster.js.map +3 -3
- package/package.json +1 -1
- package/src/wire.js +16 -4
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 = 1000 // 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
|
|
@@ -277,6 +277,18 @@ const Wire = opt => {
|
|
|
277
277
|
)
|
|
278
278
|
})
|
|
279
279
|
}
|
|
280
|
+
|
|
281
|
+
// Always broadcast original data to other peers even if no local update
|
|
282
|
+
const sendResult = send(
|
|
283
|
+
JSON.stringify({
|
|
284
|
+
"#": dup.track(utils.text.random(9)),
|
|
285
|
+
put: msg.put,
|
|
286
|
+
}),
|
|
287
|
+
)
|
|
288
|
+
if (sendResult && sendResult.err) {
|
|
289
|
+
console.log(`Error broadcasting put: ${sendResult.err}`)
|
|
290
|
+
}
|
|
291
|
+
|
|
280
292
|
if (Object.keys(update.defer).length) {
|
|
281
293
|
setTimeout(() => put({put: update.defer}, send), update.wait)
|
|
282
294
|
}
|
|
@@ -640,8 +652,8 @@ const Wire = opt => {
|
|
|
640
652
|
|
|
641
653
|
// Schedule processing of next message if queue not empty
|
|
642
654
|
if (messageQueue.length > 0) {
|
|
643
|
-
// Add delay between messages to respect rate
|
|
644
|
-
queueProcessor = setTimeout(processQueue,
|
|
655
|
+
// Add delay between messages to respect rate limit
|
|
656
|
+
queueProcessor = setTimeout(processQueue, 100)
|
|
645
657
|
} else {
|
|
646
658
|
queueProcessor = null
|
|
647
659
|
}
|
|
@@ -685,7 +697,7 @@ const Wire = opt => {
|
|
|
685
697
|
messageQueue.push(data)
|
|
686
698
|
// Start queue processor if not already running
|
|
687
699
|
if (!queueProcessor) {
|
|
688
|
-
queueProcessor = setTimeout(processQueue,
|
|
700
|
+
queueProcessor = setTimeout(processQueue, 100)
|
|
689
701
|
}
|
|
690
702
|
}
|
|
691
703
|
if (!(opt.peers instanceof Array)) {
|