@nxtedition/lib 19.8.15 → 19.8.16

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.
Files changed (2) hide show
  1. package/couch.js +25 -11
  2. package/package.json +1 -1
package/couch.js CHANGED
@@ -220,17 +220,31 @@ export function makeCouch(opts) {
220
220
  const limit = options.limit
221
221
 
222
222
  try {
223
- yield* _changes({
224
- batched,
225
- live,
226
- retry,
227
- limit,
228
- params,
229
- method,
230
- body,
231
- signal: ac.signal,
232
- client,
233
- })
223
+ // Limit request duration to allow server to load balance.
224
+ const socketCount = 64 * 1024
225
+ let remaining = Number(limit) || Infinity
226
+ while (remaining > 0) {
227
+ let count = 0
228
+ for await (const changes of _changes({
229
+ batched,
230
+ live,
231
+ retry,
232
+ limit: Math.min(remaining, socketCount),
233
+ params,
234
+ method,
235
+ body,
236
+ signal: ac.signal,
237
+ client,
238
+ })) {
239
+ yield changes
240
+ count += changes.length
241
+ remaining -= changes.length
242
+ }
243
+ assert(remaining >= 0)
244
+ if (!live && count < socketCount) {
245
+ return
246
+ }
247
+ }
234
248
  } finally {
235
249
  ac.abort()
236
250
  if (signal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "19.8.15",
3
+ "version": "19.8.16",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",