@nxtedition/lib 28.0.25 → 28.0.27
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 +50 -4
- package/http.js +4 -4
- package/package.json +3 -3
package/app.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs'
|
|
2
2
|
import * as inspector from 'node:inspector'
|
|
3
3
|
import fs from 'node:fs'
|
|
4
|
+
import util from 'node:util'
|
|
4
5
|
import os from 'node:os'
|
|
5
6
|
import http from 'node:http'
|
|
6
7
|
import net from 'node:net'
|
|
@@ -40,6 +41,7 @@ import makeUnderPressure from './under-pressure.js'
|
|
|
40
41
|
import { nice } from '@nxtedition/sched'
|
|
41
42
|
import { setAffinity } from './numa.js'
|
|
42
43
|
import { getContainerMemoryLimit, getContainerMemoryUsage } from './memory.js'
|
|
44
|
+
import { serializeError } from './errors.js'
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
47
|
* @param {object} appConfig
|
|
@@ -688,6 +690,8 @@ export function makeApp(appConfig, onTerminateOrMeta, metaOrNull) {
|
|
|
688
690
|
sockets: globalThis.__undici_sockets?.size ?? 0,
|
|
689
691
|
}
|
|
690
692
|
|
|
693
|
+
const errors = []
|
|
694
|
+
|
|
691
695
|
if (statsMap) {
|
|
692
696
|
memory.totalHeapTotal = 0
|
|
693
697
|
memory.totalHeapUsed = 0
|
|
@@ -707,6 +711,10 @@ export function makeApp(appConfig, onTerminateOrMeta, metaOrNull) {
|
|
|
707
711
|
http.totalPending += stats.http?.pending ?? 0
|
|
708
712
|
|
|
709
713
|
undici.totalSockets += stats.undici?.sockets ?? 0
|
|
714
|
+
|
|
715
|
+
if (stats.error) {
|
|
716
|
+
errors.push(stats.error)
|
|
717
|
+
}
|
|
710
718
|
}
|
|
711
719
|
}
|
|
712
720
|
|
|
@@ -718,6 +726,9 @@ export function makeApp(appConfig, onTerminateOrMeta, metaOrNull) {
|
|
|
718
726
|
couch: couch?.stats,
|
|
719
727
|
lag: toobusy?.lag(),
|
|
720
728
|
version: process.version,
|
|
729
|
+
error: errors.length
|
|
730
|
+
? serializeError(errors.length > 1 ? new AggregateError(errors) : errors[0])
|
|
731
|
+
: null,
|
|
721
732
|
underPressure: underPressure?.isUnderPressure() ? underPressure.getPressure() : null,
|
|
722
733
|
cpu,
|
|
723
734
|
memory,
|
|
@@ -757,7 +768,15 @@ export function makeApp(appConfig, onTerminateOrMeta, metaOrNull) {
|
|
|
757
768
|
appDestroyers.unshift(
|
|
758
769
|
monitorProviders.stats$
|
|
759
770
|
.subscribe((stats) => {
|
|
760
|
-
|
|
771
|
+
try {
|
|
772
|
+
statsBC.postMessage({ id: threadId, data: JSON.stringify(JSON.parse(stats)) })
|
|
773
|
+
} catch (err) {
|
|
774
|
+
statsBC.postMessage({ id: threadId, data: { error: serializeError(err) } })
|
|
775
|
+
logger.error(
|
|
776
|
+
{ err, data: util.inspect(stats, { depth: 16 }) },
|
|
777
|
+
'stats broadcast failed',
|
|
778
|
+
)
|
|
779
|
+
}
|
|
761
780
|
})
|
|
762
781
|
.add(() => {
|
|
763
782
|
statsBC.postMessage({ id: threadId, data: undefined })
|
|
@@ -831,9 +850,17 @@ export function makeApp(appConfig, onTerminateOrMeta, metaOrNull) {
|
|
|
831
850
|
makeStatusPipe('status'),
|
|
832
851
|
),
|
|
833
852
|
monitorProviders.stats$?.pipe(
|
|
834
|
-
rxjs.map(({ memory, heap, utilization, undici, http }) => {
|
|
853
|
+
rxjs.map(({ memory, heap, utilization, undici, http, error }) => {
|
|
835
854
|
const messages = []
|
|
836
855
|
|
|
856
|
+
if (error) {
|
|
857
|
+
messages.push({
|
|
858
|
+
id: 'app:monitor_stats_error',
|
|
859
|
+
level: 50,
|
|
860
|
+
msg: `Monitor Stats Error: ${error.message}`,
|
|
861
|
+
})
|
|
862
|
+
}
|
|
863
|
+
|
|
837
864
|
if (memory?.containerLimit) {
|
|
838
865
|
const usagePercent = (memory.containerUsage / memory.containerLimit) * 100
|
|
839
866
|
messages.push({
|
|
@@ -1066,8 +1093,27 @@ export function makeApp(appConfig, onTerminateOrMeta, metaOrNull) {
|
|
|
1066
1093
|
|
|
1067
1094
|
appDestroyers.unshift(
|
|
1068
1095
|
monitorProviders.status$
|
|
1069
|
-
.subscribe((
|
|
1070
|
-
|
|
1096
|
+
.subscribe((status) => {
|
|
1097
|
+
try {
|
|
1098
|
+
statusBC.postMessage({ id: threadId, data: JSON.stringify(JSON.parse(status)) })
|
|
1099
|
+
} catch (err) {
|
|
1100
|
+
statusBC.postMessage({
|
|
1101
|
+
id: threadId,
|
|
1102
|
+
data: {
|
|
1103
|
+
messages: [
|
|
1104
|
+
{
|
|
1105
|
+
id: 'app:monitor_status_broadcast_error_' + threadId,
|
|
1106
|
+
level: 50,
|
|
1107
|
+
msg: `Monitor Status Error: ${err.message}`,
|
|
1108
|
+
},
|
|
1109
|
+
],
|
|
1110
|
+
},
|
|
1111
|
+
})
|
|
1112
|
+
logger.error(
|
|
1113
|
+
{ err, data: util.inspect(status, { depth: 16 }) },
|
|
1114
|
+
'status broadcast failed',
|
|
1115
|
+
)
|
|
1116
|
+
}
|
|
1071
1117
|
})
|
|
1072
1118
|
.add(() => {
|
|
1073
1119
|
statusBC.postMessage({ id: threadId, data: undefined })
|
package/http.js
CHANGED
|
@@ -572,7 +572,7 @@ export class ServerResponse extends http.ServerResponse {
|
|
|
572
572
|
|
|
573
573
|
/**
|
|
574
574
|
* @param {Buffer|string} chunk
|
|
575
|
-
* @param {
|
|
575
|
+
* @param {NodeJS.BufferEncoding} [encoding]
|
|
576
576
|
* @param {(err: Error) => void} [callback]
|
|
577
577
|
*/
|
|
578
578
|
write(chunk, encoding, callback) {
|
|
@@ -599,7 +599,7 @@ export class ServerResponse extends http.ServerResponse {
|
|
|
599
599
|
|
|
600
600
|
/**
|
|
601
601
|
* @param {Buffer|string} chunk
|
|
602
|
-
* @param {
|
|
602
|
+
* @param {NodeJS.BufferEncoding} [encoding]
|
|
603
603
|
* @param {(err: Error) => void} [callback]
|
|
604
604
|
*/
|
|
605
605
|
end(chunk, encoding, callback) {
|
|
@@ -811,7 +811,7 @@ export class Http2ServerResponse extends http2.Http2ServerResponse {
|
|
|
811
811
|
|
|
812
812
|
/**
|
|
813
813
|
* @param {Buffer|string} chunk
|
|
814
|
-
* @param {
|
|
814
|
+
* @param {NodeJS.BufferEncoding} [encoding]
|
|
815
815
|
* @param {(err: Error) => void} [callback]
|
|
816
816
|
*/
|
|
817
817
|
write(chunk, encoding, callback) {
|
|
@@ -838,7 +838,7 @@ export class Http2ServerResponse extends http2.Http2ServerResponse {
|
|
|
838
838
|
|
|
839
839
|
/**
|
|
840
840
|
* @param {Buffer|string} chunk
|
|
841
|
-
* @param {
|
|
841
|
+
* @param {NodeJS.BufferEncoding} [encoding]
|
|
842
842
|
* @param {(err: Error) => void} [callback]
|
|
843
843
|
*/
|
|
844
844
|
end(chunk, encoding, callback) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "28.0.
|
|
3
|
+
"version": "28.0.27",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@elastic/transport": "^8.9.3",
|
|
53
53
|
"@nxtedition/nxt-undici": "^7.1.9",
|
|
54
54
|
"@nxtedition/sched": "^1.0.2",
|
|
55
|
-
"@nxtedition/template": "^1.0.
|
|
55
|
+
"@nxtedition/template": "^1.0.11",
|
|
56
56
|
"@nxtedition/weak-cache": "^1.0.2",
|
|
57
57
|
"@nxtedition/yield": "^1.0.2",
|
|
58
58
|
"diff": "5.2.0",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"canvas": "^3.1.0",
|
|
93
93
|
"rxjs": "^7.0.0"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "974526e5bb5a547662e75a360137e1e590f0a399"
|
|
96
96
|
}
|