@nxtedition/lib 22.0.3 → 22.0.5

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 CHANGED
@@ -8,7 +8,6 @@ import stream from 'node:stream'
8
8
  import { Buffer } from 'node:buffer'
9
9
  import { getDockerSecretsSync } from './docker-secrets.js'
10
10
  import fp from 'lodash/fp.js'
11
- import { mkdirSync } from 'node:fs'
12
11
  import {
13
12
  isMainThread,
14
13
  parentPort,
@@ -46,14 +45,6 @@ export function makeApp(appConfig, onTerminate) {
46
45
  let logger
47
46
  let trace
48
47
 
49
- try {
50
- mkdirSync('./.nxt')
51
- } catch (err) {
52
- if (err.code !== 'EEXIST') {
53
- throw err
54
- }
55
- }
56
-
57
48
  /** @type {Array<rxjs.Subscription|Function|AsyncFunction|Disposable|AsyncDisposable>} */
58
49
  const destroyers = []
59
50
 
@@ -885,7 +876,8 @@ export function makeApp(appConfig, onTerminate) {
885
876
 
886
877
  // TODO (fix): Determinisitc port also in dev mode... hash of something?
887
878
  const port =
888
- appConfig.inspect?.port ?? (isProduction ? 38603 : Math.floor(38000 + Math.random() * 1000))
879
+ appConfig.inspect?.port ??
880
+ (isProduction ? 38603 : Math.floor(38000 + Math.random() * 10000))
889
881
  const server = http
890
882
  .createServer(async (req, res) => {
891
883
  try {
package/couch.js CHANGED
@@ -43,9 +43,7 @@ export function makeCouch(opts) {
43
43
  )
44
44
 
45
45
  const defaultClientOpts = {
46
- keepAliveTimeout: 2 * 60e3,
47
- headersTimeout: 10 * 60e3,
48
- bodyTimeout: 2 * 60e3,
46
+ connectTimeout: 2e3,
49
47
  }
50
48
 
51
49
  const userAgent = config.userAgent || globalThis.userAgent
@@ -116,7 +114,7 @@ export function makeCouch(opts) {
116
114
  * @param {boolean} [options.live=false]
117
115
  * @param {number} [options.heartbeat=60000]
118
116
  * @param {function} [options.retry=null]
119
- * @param {string} [options.since=null]
117
+ * @param {string|null} [options.since=null]
120
118
  * @param {number} [options.highWaterMark=128 * 1024]
121
119
  * @param {object} [options.selector=null]
122
120
  * @param {import('pino').Logger} [options.logger=null]
@@ -1092,7 +1090,7 @@ export function request(url, opts) {
1092
1090
  const signal = opts.signal
1093
1091
 
1094
1092
  if (opts.stream) {
1095
- const handler = new StreamOutput({ signal, ...stream })
1093
+ const handler = new StreamOutput({ signal, highWaterMark: stream.highWaterMark })
1096
1094
  dispatch(dispatcher, ureq, handler)
1097
1095
  return handler
1098
1096
  } else {
package/http.js CHANGED
@@ -152,7 +152,7 @@ export async function requestMiddleware(ctx, next) {
152
152
  await thenable
153
153
  }
154
154
 
155
- assert(res.destroyed, 'response not completed')
155
+ assert(res.destroyed || res.writableEnded, 'response not completed')
156
156
 
157
157
  const elapsedTime = performance.now() - startTime
158
158
 
@@ -391,7 +391,15 @@ export class ServerResponse extends http.ServerResponse {
391
391
  super(req)
392
392
 
393
393
  this.#created = performance.now()
394
- this.#timing.connect = 0
394
+ }
395
+
396
+ assignSocket(socket) {
397
+ if (!this.destroyed) {
398
+ if (this.#timing.connect === -1) {
399
+ this.#timing.connect = performance.now() - this.#created
400
+ }
401
+ }
402
+ return super.assignSocket(socket)
395
403
  }
396
404
 
397
405
  flushHeaders() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "22.0.3",
3
+ "version": "22.0.5",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -68,6 +68,7 @@
68
68
  "lodash": "^4.17.21",
69
69
  "lru-cache": "^11.0.1",
70
70
  "mime": "^4.0.4",
71
+ "mitata": "^1.0.11",
71
72
  "moment-timezone": "^0.5.46",
72
73
  "nconf": "^0.12.1",
73
74
  "nested-error-stacks": "^2.1.1",
package/sequence.js CHANGED
@@ -20,10 +20,10 @@ const cyrb53 = (str, seed = 0) => {
20
20
  }
21
21
 
22
22
  export class Sequence {
23
- #value
23
+ #value = ''
24
24
  #parts = []
25
25
  #identity
26
- #count
26
+ #count = 0
27
27
 
28
28
  // TODO (perf): Optimize
29
29
  /**
@@ -139,7 +139,10 @@ export class Sequence {
139
139
  }
140
140
  }
141
141
  } catch (err) {
142
- throw Object.assign(new Error('Invalid sequence value'), { cause: err, data: value })
142
+ throw Object.assign(new Error('Invalid sequence value: ' + err.message), {
143
+ cause: err,
144
+ data: value,
145
+ })
143
146
  }
144
147
  }
145
148
 
@@ -184,8 +187,8 @@ export class Sequence {
184
187
  assert(Number.isFinite(sequence) && sequence >= 0)
185
188
  if (this.#parts[index * 2 + 1] !== sequence) {
186
189
  this.#parts[index * 2 + 1] = sequence
187
- this.#value = undefined
188
- this.#count = undefined
190
+ this.#value = ''
191
+ this.#count = 0
189
192
  }
190
193
  }
191
194
 
@@ -220,7 +223,7 @@ export class Sequence {
220
223
  let token = ''
221
224
  for (let n = 0; n < this.#parts.length; n += 2) {
222
225
  count += this.#parts[n + 1]
223
- token += (n === 0 ? '-' : '_') + this.#parts[n + 1] + ID_SEP + this.#parts[n]
226
+ token += (n === 0 ? '-' : '_') + this.#parts[n + 1] + ID_SEP + this.#parts[n + 0]
224
227
  }
225
228
  this.#value = String(count) + token
226
229
  }