@nxtedition/lib 23.3.19 → 23.3.20

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
@@ -272,7 +272,9 @@ export function makeApp(appConfig, onTerminate) {
272
272
  try {
273
273
  fs.mkdirSync('./.nxt', { recursive: true })
274
274
  } catch (err) {
275
- logger.warn({ err }, 'failed to create ./nxt dir')
275
+ if (err.code !== 'EACCES') {
276
+ logger.warn({ err }, 'failed to create ./nxt dir')
277
+ }
276
278
  }
277
279
 
278
280
  let toobusy
package/http.js CHANGED
@@ -65,12 +65,10 @@ export class Context {
65
65
  return this.#userAgent
66
66
  }
67
67
 
68
- /** @deprecated */
69
68
  get method() {
70
69
  return this.#req.method
71
70
  }
72
71
 
73
- /** @deprecated */
74
72
  get url() {
75
73
  if (this.#url === undefined) {
76
74
  this.#url = requestTarget(this.#req)
@@ -78,8 +76,11 @@ export class Context {
78
76
  return this.#url
79
77
  }
80
78
 
81
- /** @deprecated */
82
79
  set url(value) {
80
+ if (value instanceof URL) {
81
+ value = value.toString()
82
+ }
83
+
83
84
  if (typeof value !== 'string') {
84
85
  throw new Error('url must be a string')
85
86
  }
@@ -89,14 +90,16 @@ export class Context {
89
90
  this.#query = undefined
90
91
  }
91
92
 
92
- /** @deprecated */
93
93
  get query() {
94
94
  if (this.#query === undefined) {
95
- this.#query = this.url.search.length > 1 ? querystring.parse(this.url.search.slice(1)) : {}
95
+ this.#query =
96
+ this.url.search.length > 1 ? Object.freeze(querystring.parse(this.url.search.slice(1))) : {}
96
97
  }
97
98
  return this.#query
98
99
  }
99
100
 
101
+ set query(value) {}
102
+
100
103
  get logger() {
101
104
  return this.#logger
102
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "23.3.19",
3
+ "version": "23.3.20",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -0,0 +1,6 @@
1
+ import type { ObservableInput, OperatorFunction } from 'rxjs'
2
+
3
+ export default function combineMap<T, R>(
4
+ project: (value: T) => ObservableInput<R>,
5
+ equals?: (a: T, b: T) => boolean,
6
+ ): OperatorFunction<T[], R[]>
package/trace.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { threadId } from 'node:worker_threads'
2
- import { Pool } from 'undici'
2
+ import { request, Pool } from '@nxtedition/nxt-undici'
3
3
  import fp from 'lodash/fp.js'
4
4
 
5
5
  const maxInt = 2147483647
@@ -23,20 +23,20 @@ export function makeTrace({
23
23
 
24
24
  let pending = 0
25
25
 
26
+ const flushInterval = setInterval(flushTraces, 10e3)
27
+
26
28
  const client = new Pool(Array.isArray(url) ? url[0] : url, {
27
29
  keepAliveTimeout: 10 * 60e3,
28
30
  pipelining: 4,
29
31
  connections: 4,
30
32
  })
31
33
 
32
- const flushInterval = setInterval(flushTraces, 10e3)
33
-
34
34
  destroyers?.push(async () => {
35
35
  clearInterval(flushInterval)
36
+ await client.close()
36
37
  while (traceData) {
37
38
  await flushTraces()
38
39
  }
39
- await client.close()
40
40
  })
41
41
 
42
42
  let traceData = ''
@@ -50,18 +50,16 @@ export function makeTrace({
50
50
 
51
51
  try {
52
52
  pending += data.length
53
- await client
54
- .request({
55
- throwOnError: true,
56
- path: '/_bulk',
57
- method: 'POST',
58
- idempotent: true,
59
- headers: HEADERS,
60
- headersTimeout: 60e3,
61
- bodyTimeout: 60e3,
62
- body: data,
63
- })
64
- .then(({ body }) => body.dump())
53
+ request({
54
+ path: '/_bulk',
55
+ method: 'POST',
56
+ idempotent: true,
57
+ headers: HEADERS,
58
+ headersTimeout: 60e3,
59
+ bodyTimeout: 60e3,
60
+ body: data,
61
+ dispatcher: client,
62
+ }).then(({ body }) => body.dump())
65
63
  } catch (err) {
66
64
  logger.error({ err }, 'trace failed')
67
65
  } finally {