@nxtedition/lib 20.1.0 → 20.1.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.
Files changed (3) hide show
  1. package/app.js +2 -2
  2. package/couch.js +14 -3
  3. package/package.json +1 -1
package/app.js CHANGED
@@ -282,7 +282,7 @@ export function makeApp(appConfig, onTerminate) {
282
282
 
283
283
  process.send?.({ type: 'nxt:lag', id, currentLag })
284
284
 
285
- let appLag = currentLag$.value
285
+ let appLag = currentLag$.value ?? 0
286
286
  for (const lag of lagMap.values()) {
287
287
  appLag = Math.max(appLag, lag ?? 0)
288
288
  }
@@ -534,7 +534,7 @@ export function makeApp(appConfig, onTerminate) {
534
534
  id: 'app:toobusy_lag',
535
535
  level: lag > 1e3 ? 50 : lag > toobusy.maxLAge ? 40 : 30,
536
536
  code: 'NXT_LAG',
537
- msg: `Lag: ${lag.toFixed(2)} ms`,
537
+ msg: `Lag: ${lag?.toFixed(2) ?? '?'} ms`,
538
538
  },
539
539
  ]),
540
540
  ) ?? rxjs.of([]),
package/couch.js CHANGED
@@ -230,10 +230,11 @@ export function makeCouch(opts) {
230
230
  let remaining = Number(limit) || Infinity
231
231
  while (remaining > 0) {
232
232
  let count = 0
233
+ const limit = Math.min(remaining, socketCount)
233
234
  for await (const changes of _changes({
234
235
  live,
235
236
  retry,
236
- limit: Math.min(remaining, socketCount),
237
+ limit,
237
238
  params,
238
239
  method,
239
240
  body,
@@ -263,7 +264,17 @@ export function makeCouch(opts) {
263
264
  }
264
265
  }
265
266
 
266
- async function* _changes({ live, retry, limit, params, method, body, signal, client }) {
267
+ async function* _changes({
268
+ live,
269
+ retry,
270
+ limit,
271
+ params,
272
+ method,
273
+ body,
274
+ signal,
275
+ client,
276
+ blocking = live || !limit || limit > 256,
277
+ }) {
267
278
  let retryCount = 0
268
279
  let remaining = Number(limit) || Infinity
269
280
  while (true) {
@@ -280,7 +291,7 @@ export function makeCouch(opts) {
280
291
  origin: dbOrigin,
281
292
  query,
282
293
  idempotent: false,
283
- blocking: true,
294
+ blocking,
284
295
  method,
285
296
  body: JSON.stringify(body),
286
297
  signal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "20.1.0",
3
+ "version": "20.1.2",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",