@nxtedition/lib 23.9.14 → 23.9.15
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 +4 -0
- package/package.json +2 -3
- package/yield.js +0 -52
package/app.js
CHANGED
|
@@ -556,6 +556,10 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
556
556
|
resourceLimits,
|
|
557
557
|
utilization: performance.eventLoopUtilization?.(elu2, elu1),
|
|
558
558
|
heap: v8.getHeapStatistics(),
|
|
559
|
+
http: {
|
|
560
|
+
userAgent,
|
|
561
|
+
pending: globalThis._nxt_lib_http_pending.size,
|
|
562
|
+
},
|
|
559
563
|
}
|
|
560
564
|
}),
|
|
561
565
|
),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "23.9.
|
|
3
|
+
"version": "23.9.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -44,8 +44,7 @@
|
|
|
44
44
|
"transcript.js",
|
|
45
45
|
"docker-secrets.js",
|
|
46
46
|
"wordwrap.js",
|
|
47
|
-
"under-pressure.js"
|
|
48
|
-
"yield.js"
|
|
47
|
+
"under-pressure.js"
|
|
49
48
|
],
|
|
50
49
|
"scripts": {
|
|
51
50
|
"prepublishOnly": "pinst --disable",
|
package/yield.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { AbortError } from './errors.js'
|
|
2
|
-
|
|
3
|
-
let yieldTime = performance.now()
|
|
4
|
-
|
|
5
|
-
export function maybeYield(callback, opaque, opts) {
|
|
6
|
-
if (callback != null && typeof callback !== 'function') {
|
|
7
|
-
throw new TypeError('callback must be a function')
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const timeout = opts?.timeout ?? 50
|
|
11
|
-
|
|
12
|
-
if (!Number.isFinite(timeout) || timeout < 0) {
|
|
13
|
-
throw new TypeError('timeout must be a finite non-negative number')
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (performance.now() - yieldTime > timeout) {
|
|
17
|
-
doYield(opts, callback, opaque)
|
|
18
|
-
} else {
|
|
19
|
-
callback(opts?.signal?.aborted ? (opts.signal.reason ?? new AbortError()) : null, opaque)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export async function doYield(callback, opaque, opts) {
|
|
24
|
-
if (callback != null && typeof callback !== 'function') {
|
|
25
|
-
throw new TypeError('callback must be a function')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// TODO (fix): Use a yield queue?
|
|
29
|
-
|
|
30
|
-
setImmediate(() => {
|
|
31
|
-
resetYield(opts)
|
|
32
|
-
callback(opts?.signal?.aborted ? (opts.signal.reason ?? new AbortError()) : null, opaque)
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function resetYield(opts) {
|
|
37
|
-
yieldTime = performance.now()
|
|
38
|
-
opts?.signal?.throwIfAborted()
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
setInterval(() => {
|
|
42
|
-
yieldTime = performance.now()
|
|
43
|
-
}, 500).unref()
|
|
44
|
-
|
|
45
|
-
export const promises = {
|
|
46
|
-
maybeYield(opts, opaque) {
|
|
47
|
-
return new Promise((resolve, reject) =>
|
|
48
|
-
maybeYield((err, val) => (err ? reject(err) : resolve(val)), opaque, opts),
|
|
49
|
-
)
|
|
50
|
-
},
|
|
51
|
-
resetYield,
|
|
52
|
-
}
|