@nxtedition/lib 21.0.14 → 21.0.16
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 +8 -1
- package/http.js +3 -20
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -6,7 +6,13 @@ import stream from 'node:stream'
|
|
|
6
6
|
import { Buffer } from 'node:buffer'
|
|
7
7
|
import { getDockerSecretsSync } from './docker-secrets.js'
|
|
8
8
|
import fp from 'lodash/fp.js'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
isMainThread,
|
|
11
|
+
parentPort,
|
|
12
|
+
threadId,
|
|
13
|
+
BroadcastChannel,
|
|
14
|
+
resourceLimits,
|
|
15
|
+
} from 'node:worker_threads'
|
|
10
16
|
import deepstream from '@nxtedition/deepstream.io-client-js'
|
|
11
17
|
import { createLogger } from './logger.js'
|
|
12
18
|
import nconf from 'nconf'
|
|
@@ -492,6 +498,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
492
498
|
cpu,
|
|
493
499
|
memory,
|
|
494
500
|
totalMemory,
|
|
501
|
+
resourceLimits,
|
|
495
502
|
utilization: performance.eventLoopUtilization?.(elu2, elu1),
|
|
496
503
|
heap: v8.getHeapStatistics(),
|
|
497
504
|
}
|
package/http.js
CHANGED
|
@@ -52,20 +52,7 @@ export async function request(ctx, next) {
|
|
|
52
52
|
ctx.signal = ac.signal
|
|
53
53
|
ctx.method = req.method
|
|
54
54
|
ctx.query = ctx.url.search.length > 1 ? querystring.parse(ctx.url.search.slice(1)) : {}
|
|
55
|
-
ctx.logger =
|
|
56
|
-
req.log =
|
|
57
|
-
res.log =
|
|
58
|
-
logger.child({
|
|
59
|
-
req: {
|
|
60
|
-
id: req.id,
|
|
61
|
-
url: req.url,
|
|
62
|
-
scheme: ctx.url.protocol,
|
|
63
|
-
host: ctx.url.hostname,
|
|
64
|
-
port: ctx.url.port,
|
|
65
|
-
path: ctx.url.pathname,
|
|
66
|
-
query: ctx.query,
|
|
67
|
-
},
|
|
68
|
-
})
|
|
55
|
+
ctx.logger = req.log = res.log = logger.child({ req: { id: req.id, url: req.url } })
|
|
69
56
|
|
|
70
57
|
if (req.method === 'GET' || req.method === 'HEAD') {
|
|
71
58
|
req.resume() // Dump the body if there is one.
|
|
@@ -83,14 +70,10 @@ export async function request(ctx, next) {
|
|
|
83
70
|
await Promise.all([
|
|
84
71
|
next(),
|
|
85
72
|
new Promise((resolve, reject) => {
|
|
86
|
-
req.on('timeout', onRequestTimeout).on('error',
|
|
87
|
-
reject(err)
|
|
88
|
-
})
|
|
73
|
+
req.on('timeout', onRequestTimeout).on('error', reject)
|
|
89
74
|
res
|
|
90
75
|
.on('timeout', onResponseTimeout)
|
|
91
|
-
.on('error',
|
|
92
|
-
reject(err)
|
|
93
|
-
})
|
|
76
|
+
.on('error', reject)
|
|
94
77
|
// TODO (fix): Use 'end' once we can trust that
|
|
95
78
|
// 'end' or 'error' will always be emitted.
|
|
96
79
|
.on('close', function () {
|