@nxtedition/lib 22.0.4 → 22.0.6
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 +2 -1
- package/couch.js +3 -5
- package/http.js +15 -3
- package/package.json +14 -13
- package/sequence.js +9 -6
package/app.js
CHANGED
|
@@ -876,7 +876,8 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
876
876
|
|
|
877
877
|
// TODO (fix): Determinisitc port also in dev mode... hash of something?
|
|
878
878
|
const port =
|
|
879
|
-
appConfig.inspect?.port ??
|
|
879
|
+
appConfig.inspect?.port ??
|
|
880
|
+
(isProduction ? 38603 : Math.floor(38000 + Math.random() * 10000))
|
|
880
881
|
const server = http
|
|
881
882
|
.createServer(async (req, res) => {
|
|
882
883
|
try {
|
package/couch.js
CHANGED
|
@@ -43,9 +43,7 @@ export function makeCouch(opts) {
|
|
|
43
43
|
)
|
|
44
44
|
|
|
45
45
|
const defaultClientOpts = {
|
|
46
|
-
|
|
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,
|
|
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
|
@@ -99,6 +99,10 @@ export class Context {
|
|
|
99
99
|
return this.#logger
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
set logger(val) {
|
|
103
|
+
this.#logger = val
|
|
104
|
+
}
|
|
105
|
+
''
|
|
102
106
|
get req() {
|
|
103
107
|
return this.#req
|
|
104
108
|
}
|
|
@@ -152,7 +156,7 @@ export async function requestMiddleware(ctx, next) {
|
|
|
152
156
|
await thenable
|
|
153
157
|
}
|
|
154
158
|
|
|
155
|
-
assert(res.destroyed, 'response not completed')
|
|
159
|
+
assert(res.destroyed || res.writableEnded, 'response not completed')
|
|
156
160
|
|
|
157
161
|
const elapsedTime = performance.now() - startTime
|
|
158
162
|
|
|
@@ -238,7 +242,7 @@ export async function requestMiddleware(ctx, next) {
|
|
|
238
242
|
} finally {
|
|
239
243
|
pendingSet.delete(ctx)
|
|
240
244
|
|
|
241
|
-
if (!res.writableEnded) {
|
|
245
|
+
if (!res.writableEnded && !res.destroyed) {
|
|
242
246
|
res.destroy()
|
|
243
247
|
logger.debug('request destroyed')
|
|
244
248
|
}
|
|
@@ -391,7 +395,15 @@ export class ServerResponse extends http.ServerResponse {
|
|
|
391
395
|
super(req)
|
|
392
396
|
|
|
393
397
|
this.#created = performance.now()
|
|
394
|
-
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
assignSocket(socket) {
|
|
401
|
+
if (!this.destroyed) {
|
|
402
|
+
if (this.#timing.connect === -1) {
|
|
403
|
+
this.#timing.connect = performance.now() - this.#created
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return super.assignSocket(socket)
|
|
395
407
|
}
|
|
396
408
|
|
|
397
409
|
flushHeaders() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "22.0.
|
|
3
|
+
"version": "22.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"singleQuote": true
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@aws-sdk/client-s3": "^3.
|
|
58
|
-
"@elastic/elasticsearch": "^8.
|
|
57
|
+
"@aws-sdk/client-s3": "^3.696.0",
|
|
58
|
+
"@elastic/elasticsearch": "^8.16.1",
|
|
59
59
|
"@elastic/transport": "^8.9.1",
|
|
60
|
-
"@nxtedition/nxt-undici": "^4.2.
|
|
60
|
+
"@nxtedition/nxt-undici": "^4.2.26",
|
|
61
61
|
"content-type": "^1.0.5",
|
|
62
62
|
"date-fns": "^3.6.0",
|
|
63
63
|
"fast-querystring": "^1.1.1",
|
|
@@ -66,42 +66,43 @@
|
|
|
66
66
|
"json5": "^2.2.3",
|
|
67
67
|
"koa-compose": "^4.1.0",
|
|
68
68
|
"lodash": "^4.17.21",
|
|
69
|
-
"lru-cache": "^11.0.
|
|
69
|
+
"lru-cache": "^11.0.2",
|
|
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",
|
|
74
75
|
"object-hash": "^3.0.0",
|
|
75
76
|
"p-queue": "^8.0.1",
|
|
76
77
|
"pino": "^9.5.0",
|
|
77
|
-
"qs": "^6.13.
|
|
78
|
+
"qs": "^6.13.1",
|
|
78
79
|
"request-target": "^1.0.2",
|
|
79
80
|
"smpte-timecode": "^1.3.6",
|
|
80
81
|
"split-string": "^6.0.0",
|
|
81
|
-
"undici": "^6.
|
|
82
|
+
"undici": "^6.21.0",
|
|
82
83
|
"url-join": "^5.0.0",
|
|
83
84
|
"xuid": "^4.1.3",
|
|
84
85
|
"yocto-queue": "^1.1.1"
|
|
85
86
|
},
|
|
86
87
|
"devDependencies": {
|
|
87
88
|
"@nxtedition/deepstream.io-client-js": ">=25.6.3",
|
|
88
|
-
"@types/lodash": "^4.17.
|
|
89
|
-
"@types/node": "^22.
|
|
90
|
-
"eslint": "^9.
|
|
89
|
+
"@types/lodash": "^4.17.13",
|
|
90
|
+
"@types/node": "^22.9.1",
|
|
91
|
+
"eslint": "^9.15.0",
|
|
91
92
|
"eslint-config-prettier": "^9.1.0",
|
|
92
93
|
"eslint-config-standard": "^17.0.0",
|
|
93
94
|
"eslint-plugin-import": "^2.31.0",
|
|
94
|
-
"eslint-plugin-n": "^17.
|
|
95
|
+
"eslint-plugin-n": "^17.13.2",
|
|
95
96
|
"eslint-plugin-node": "^11.1.0",
|
|
96
97
|
"eslint-plugin-promise": "^7.1.0",
|
|
97
|
-
"husky": "^9.1.
|
|
98
|
+
"husky": "^9.1.7",
|
|
98
99
|
"lint-staged": "^15.2.10",
|
|
99
100
|
"pinst": "^3.0.0",
|
|
100
101
|
"prettier": "^3.3.3",
|
|
101
102
|
"rxjs": "^7.5.6",
|
|
102
103
|
"send": "^0.18.0",
|
|
103
104
|
"tap": "^21.0.1",
|
|
104
|
-
"typescript-eslint": "^8.
|
|
105
|
+
"typescript-eslint": "^8.15.0"
|
|
105
106
|
},
|
|
106
107
|
"peerDependencies": {
|
|
107
108
|
"@elastic/elasticsearch": "^8.6.0",
|
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'
|
|
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 =
|
|
188
|
-
this.#count =
|
|
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
|
}
|