@nxtedition/lib 19.8.14 → 19.8.15

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 -29
  2. package/package.json +7 -7
package/couch.js CHANGED
@@ -7,7 +7,13 @@ import tp from 'timers/promises'
7
7
  import { defaultDelay as delay } from './http.js'
8
8
  import urljoin from 'url-join'
9
9
  import { AbortError } from './errors.js'
10
- import { dispatch, Agent, Pool, parseHeaders } from '@nxtedition/nxt-undici'
10
+ import {
11
+ dispatch,
12
+ Agent,
13
+ Pool,
14
+ parseHeaders,
15
+ request as undiciRequest,
16
+ } from '@nxtedition/nxt-undici'
11
17
 
12
18
  // https://github.com/fastify/fastify/blob/main/lib/reqIdGenFactory.js
13
19
  // 2,147,483,647 (2^31 − 1) stands for max SMI value (an internal optimization of V8).
@@ -214,31 +220,17 @@ export function makeCouch(opts) {
214
220
  const limit = options.limit
215
221
 
216
222
  try {
217
- // Don't stay connected to the same socket to allow server to load balance.
218
- const socketCount = 128 * 1024
219
- let remaining = Number(limit) || Infinity
220
- while (remaining > 0) {
221
- let count = 0
222
- for await (const changes of _changes({
223
- batched,
224
- live,
225
- retry,
226
- limit: Math.min(remaining, socketCount),
227
- params,
228
- method,
229
- body,
230
- signal: ac.signal,
231
- client,
232
- })) {
233
- yield changes
234
- count += changes.length
235
- remaining -= changes.length
236
- }
237
- assert(remaining >= 0)
238
- if (!live && count < socketCount) {
239
- return
240
- }
241
- }
223
+ yield* _changes({
224
+ batched,
225
+ live,
226
+ retry,
227
+ limit,
228
+ params,
229
+ method,
230
+ body,
231
+ signal: ac.signal,
232
+ client,
233
+ })
242
234
  } finally {
243
235
  ac.abort()
244
236
  if (signal) {
@@ -265,6 +257,7 @@ export function makeCouch(opts) {
265
257
 
266
258
  const ureq = {
267
259
  path: `${dbPathname}/_changes`,
260
+ origin: dbOrigin,
268
261
  query,
269
262
  idempotent: false,
270
263
  blocking: true,
@@ -278,9 +271,10 @@ export function makeCouch(opts) {
278
271
  },
279
272
  bodyTimeout: 2 * (params.heartbeat || 60e3),
280
273
  highWaterMark: 256 * 1024,
274
+ dispatcher: client,
281
275
  }
282
276
 
283
- const ures = await client.request(ureq)
277
+ const ures = await undiciRequest(ureq)
284
278
 
285
279
  if (ures.statusCode < 200 || ures.statusCode >= 300) {
286
280
  throw makeError(ureq, {
@@ -480,10 +474,11 @@ export function makeCouch(opts) {
480
474
  method,
481
475
  body: typeof body === 'object' && body ? JSON.stringify(body) : body,
482
476
  headers,
477
+ dispatcher: client,
483
478
  }
484
479
 
485
480
  return new Promise((resolve, reject) =>
486
- client.dispatch(req, {
481
+ dispatch(req, {
487
482
  resolve,
488
483
  reject,
489
484
  signal,
@@ -731,11 +726,12 @@ export function makeCouch(opts) {
731
726
  }
732
727
 
733
728
  async function up(params, body, { client = defaultClient, signal = null } = {}) {
734
- const res = await client.request({
729
+ const res = await request({
735
730
  path: '/_up',
736
731
  method: 'GET',
737
732
  signal,
738
733
  throwOnError: true,
734
+ dispatcher: client,
739
735
  })
740
736
  return await res.body.json()
741
737
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "19.8.14",
3
+ "version": "19.8.15",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -79,10 +79,10 @@
79
79
  "**/*.d.ts"
80
80
  ],
81
81
  "dependencies": {
82
- "@aws-sdk/client-s3": "^3.606.0",
82
+ "@aws-sdk/client-s3": "^3.614.0",
83
83
  "@elastic/elasticsearch": "^8.14.0",
84
- "@elastic/transport": "^8.6.1",
85
- "@nxtedition/nxt-undici": "^4.0.1",
84
+ "@elastic/transport": "^8.7.0",
85
+ "@nxtedition/nxt-undici": "^4.1.3",
86
86
  "content-type": "^1.0.5",
87
87
  "date-fns": "^3.6.0",
88
88
  "fast-querystring": "^1.1.1",
@@ -91,14 +91,14 @@
91
91
  "json5": "^2.2.3",
92
92
  "koa-compose": "^4.1.0",
93
93
  "lodash": "^4.17.21",
94
- "mime": "^4.0.1",
94
+ "mime": "^4.0.4",
95
95
  "moment-timezone": "^0.5.45",
96
96
  "nconf": "^0.12.1",
97
97
  "nested-error-stacks": "^2.1.1",
98
98
  "object-hash": "^3.0.0",
99
99
  "p-queue": "^8.0.1",
100
100
  "pino": "^9.2.0",
101
- "qs": "^6.12.1",
101
+ "qs": "^6.12.3",
102
102
  "request-target": "^1.0.2",
103
103
  "smpte-timecode": "^1.3.6",
104
104
  "split-string": "^6.0.0",
@@ -109,7 +109,7 @@
109
109
  "devDependencies": {
110
110
  "@nxtedition/deepstream.io-client-js": ">=24.2.4",
111
111
  "@types/lodash": "^4.17.6",
112
- "@types/node": "^20.14.9",
112
+ "@types/node": "^20.14.10",
113
113
  "eslint": "^8.0.0",
114
114
  "eslint-config-prettier": "^9.1.0",
115
115
  "eslint-config-standard": "^17.0.0",