@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mblaney/holster",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "Holster is a service that allows synchronising data between devices using Node, Deno, Bun or the browser.",
5
5
  "type": "module",
6
6
  "main": "index.js",
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 = 300 // 5 requests per second
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 limits (300 req/min = 200ms)
644
- queueProcessor = setTimeout(processQueue, 250)
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, 250)
700
+ queueProcessor = setTimeout(processQueue, 100)
689
701
  }
690
702
  }
691
703
  if (!(opt.peers instanceof Array)) {