@nxtedition/lib 19.0.1 → 19.0.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 (2) hide show
  1. package/couch.js +9 -10
  2. package/package.json +1 -1
package/couch.js CHANGED
@@ -6,6 +6,7 @@ import { defaultDelay as delay } from './http.js'
6
6
  import querystring from 'querystring'
7
7
  import urljoin from 'url-join'
8
8
  import undici from 'undici'
9
+ import { AbortError } from './errors.js'
9
10
 
10
11
  // https://github.com/fastify/fastify/blob/main/lib/reqIdGenFactory.js
11
12
  // 2,147,483,647 (2^31 − 1) stands for max SMI value (an internal optimization of V8).
@@ -114,7 +115,6 @@ export function makeCouch(opts) {
114
115
  return createError(res.status, {
115
116
  reason,
116
117
  error,
117
- body: req.body ? JSON.stringify(req.body).slice(0, 4096) : null,
118
118
  data: {
119
119
  req: {
120
120
  origin: dbOrigin,
@@ -216,13 +216,13 @@ export function makeCouch(opts) {
216
216
 
217
217
  if (signal) {
218
218
  if (signal.aborted) {
219
- ac.abort()
220
- } else {
221
- if (signal.on) {
222
- signal.on('abort', onAbort)
223
- } else if (signal.addEventListener) {
224
- signal.addEventListener('abort', onAbort)
225
- }
219
+ throw signal.reason ?? new AbortError()
220
+ }
221
+
222
+ if (signal.on) {
223
+ signal.on('abort', onAbort)
224
+ } else if (signal.addEventListener) {
225
+ signal.addEventListener('abort', onAbort)
226
226
  }
227
227
  }
228
228
 
@@ -251,7 +251,6 @@ export function makeCouch(opts) {
251
251
  'request-id': genReqId(),
252
252
  ...(body ? { 'content-type': 'application/json' } : {}),
253
253
  },
254
- throwOnError: true,
255
254
  highWaterMark: 256 * 1024, // TODO (fix): Needs support in undici...
256
255
  bodyTimeout: 2 * (params.heartbeat || 60e3),
257
256
  }
@@ -290,8 +289,8 @@ export function makeCouch(opts) {
290
289
  if (live) {
291
290
  const data = JSON.parse(line)
292
291
  if (data.last_seq) {
292
+ assert(data.last_seq, 'invalid last_seq: ' + data.last_seq)
293
293
  params.since = data.last_seq
294
- assert(params.since, 'invalid last_seq: ' + params.since)
295
294
  } else {
296
295
  params.since = data.seq || params.since
297
296
  changes.push(data)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "19.0.1",
3
+ "version": "19.0.2",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",