@nxtedition/lib 14.0.19 → 14.0.21
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/couch.js +21 -61
- package/package.json +1 -1
package/couch.js
CHANGED
|
@@ -231,7 +231,7 @@ module.exports = function (opts) {
|
|
|
231
231
|
...options.query,
|
|
232
232
|
feed: 'continuous',
|
|
233
233
|
})}`,
|
|
234
|
-
idempotent:
|
|
234
|
+
idempotent: false,
|
|
235
235
|
blocking: true,
|
|
236
236
|
method,
|
|
237
237
|
body: JSON.stringify(body),
|
|
@@ -241,78 +241,38 @@ module.exports = function (opts) {
|
|
|
241
241
|
'request-id': genReqId(),
|
|
242
242
|
...(body ? { 'content-type': 'application/json' } : {}),
|
|
243
243
|
},
|
|
244
|
+
throwOnError: true,
|
|
244
245
|
highWaterMark: 128 * 1024, // TODO (fix): Needs support in undici...
|
|
245
246
|
bodyTimeout: 2 * (params.heartbeat || 60e3),
|
|
246
247
|
}
|
|
247
|
-
const res = await client.request(req)
|
|
248
248
|
|
|
249
|
-
|
|
250
|
-
throw makeError(req, {
|
|
251
|
-
status: res.statusCode,
|
|
252
|
-
headers: res.headers,
|
|
253
|
-
data: await res.body.text(),
|
|
254
|
-
})
|
|
255
|
-
}
|
|
249
|
+
const res = await client.request(req)
|
|
256
250
|
|
|
257
251
|
retryCount = 0
|
|
258
252
|
|
|
259
|
-
const src = res.body
|
|
260
|
-
|
|
261
|
-
let resume = null
|
|
262
|
-
let error = null
|
|
263
253
|
let str = ''
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
try {
|
|
278
|
-
while (true) {
|
|
279
|
-
const chunk = src.read()
|
|
280
|
-
if (chunk !== null) {
|
|
281
|
-
str += chunk
|
|
282
|
-
} else if (error) {
|
|
283
|
-
throw error
|
|
284
|
-
} else {
|
|
285
|
-
const lines = str.split('\n')
|
|
286
|
-
str = lines.pop() ?? ''
|
|
287
|
-
|
|
288
|
-
if (lines.length === 0) {
|
|
289
|
-
await new Promise((resolve) => {
|
|
290
|
-
resume = resolve
|
|
291
|
-
})
|
|
254
|
+
for await (const chunk of res.body) {
|
|
255
|
+
const lines = (str + chunk).split('\n')
|
|
256
|
+
str = lines.pop() ?? ''
|
|
257
|
+
|
|
258
|
+
const results = batched ? [] : null
|
|
259
|
+
for (const line of lines) {
|
|
260
|
+
if (line) {
|
|
261
|
+
const change = JSON.parse(line)
|
|
262
|
+
if (change.seq) {
|
|
263
|
+
params.since = change.seq
|
|
264
|
+
}
|
|
265
|
+
if (results) {
|
|
266
|
+
results.push(change)
|
|
292
267
|
} else {
|
|
293
|
-
|
|
294
|
-
for (const line of lines) {
|
|
295
|
-
if (line) {
|
|
296
|
-
const change = JSON.parse(line)
|
|
297
|
-
if (change.seq) {
|
|
298
|
-
params.since = change.seq
|
|
299
|
-
}
|
|
300
|
-
if (results) {
|
|
301
|
-
results.push(change)
|
|
302
|
-
} else {
|
|
303
|
-
yield change
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (results?.length) {
|
|
309
|
-
yield results
|
|
310
|
-
}
|
|
268
|
+
yield change
|
|
311
269
|
}
|
|
312
270
|
}
|
|
313
271
|
}
|
|
314
|
-
|
|
315
|
-
|
|
272
|
+
|
|
273
|
+
if (results?.length) {
|
|
274
|
+
yield results
|
|
275
|
+
}
|
|
316
276
|
}
|
|
317
277
|
}
|
|
318
278
|
|