@nxtedition/lib 19.0.16 → 19.0.18
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/app.js +1 -1
- package/couch.js +23 -20
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -661,7 +661,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
663
|
|
|
664
|
-
if (appConfig.trace) {
|
|
664
|
+
if (appConfig.trace && isProduction) {
|
|
665
665
|
const traceConfig = { ...appConfig.trace, ...config.trace }
|
|
666
666
|
if (traceConfig.url) {
|
|
667
667
|
trace = makeTrace({ ...traceConfig, destroyers: appDestroyers, logger, serviceName })
|
package/couch.js
CHANGED
|
@@ -230,6 +230,7 @@ export function makeCouch(opts) {
|
|
|
230
230
|
let remaining = Number(options.limit) || Infinity
|
|
231
231
|
try {
|
|
232
232
|
while (true) {
|
|
233
|
+
let src
|
|
233
234
|
try {
|
|
234
235
|
const query = { ...params, feed: live ? 'continuous' : 'normal' }
|
|
235
236
|
|
|
@@ -237,7 +238,7 @@ export function makeCouch(opts) {
|
|
|
237
238
|
query.limit = remaining
|
|
238
239
|
}
|
|
239
240
|
|
|
240
|
-
const
|
|
241
|
+
const ureq = {
|
|
241
242
|
path: `${dbPathname}/_changes`,
|
|
242
243
|
query,
|
|
243
244
|
idempotent: false,
|
|
@@ -254,18 +255,18 @@ export function makeCouch(opts) {
|
|
|
254
255
|
bodyTimeout: 2 * (params.heartbeat || 60e3),
|
|
255
256
|
}
|
|
256
257
|
|
|
257
|
-
const
|
|
258
|
+
const ures = await client.request(ureq)
|
|
258
259
|
|
|
259
|
-
if (
|
|
260
|
-
throw makeError(
|
|
261
|
-
status:
|
|
262
|
-
headers:
|
|
263
|
-
data: await
|
|
260
|
+
if (ures.statusCode < 200 || ures.statusCode >= 300) {
|
|
261
|
+
throw makeError(ureq, {
|
|
262
|
+
status: ures.statusCode,
|
|
263
|
+
headers: ures.headers,
|
|
264
|
+
data: await ures.body.text(),
|
|
264
265
|
})
|
|
265
266
|
}
|
|
266
267
|
|
|
267
|
-
|
|
268
|
-
|
|
268
|
+
src = stream.pipeline(
|
|
269
|
+
ures.body,
|
|
269
270
|
split2('\n', { writableHighWaterMark: highWaterMark ?? 256 * 1024 }),
|
|
270
271
|
() => {},
|
|
271
272
|
)
|
|
@@ -277,24 +278,24 @@ export function makeCouch(opts) {
|
|
|
277
278
|
let ended = false
|
|
278
279
|
let state = 0
|
|
279
280
|
|
|
281
|
+
function maybeResume() {
|
|
282
|
+
if (resume) {
|
|
283
|
+
resume()
|
|
284
|
+
resume = null
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
280
288
|
src
|
|
281
|
-
.on('readable',
|
|
282
|
-
if (resume) {
|
|
283
|
-
resume()
|
|
284
|
-
resume = null
|
|
285
|
-
}
|
|
286
|
-
})
|
|
289
|
+
.on('readable', maybeResume)
|
|
287
290
|
.on('error', (err) => {
|
|
288
291
|
error = err
|
|
289
|
-
|
|
290
|
-
if (resume) {
|
|
291
|
-
resume()
|
|
292
|
-
resume = null
|
|
293
|
-
}
|
|
292
|
+
maybeResume()
|
|
294
293
|
})
|
|
295
294
|
.on('end', () => {
|
|
296
295
|
ended = true
|
|
296
|
+
maybeResume()
|
|
297
297
|
})
|
|
298
|
+
.on('close', maybeResume)
|
|
298
299
|
|
|
299
300
|
while (true) {
|
|
300
301
|
const line = src.read()
|
|
@@ -365,6 +366,8 @@ export function makeCouch(opts) {
|
|
|
365
366
|
} else {
|
|
366
367
|
await delay(err, retryCount, { signal })
|
|
367
368
|
}
|
|
369
|
+
} finally {
|
|
370
|
+
src?.on('error', () => {}).destroy()
|
|
368
371
|
}
|
|
369
372
|
}
|
|
370
373
|
} finally {
|