@nxtedition/lib 23.0.0 → 23.0.1
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 +11 -20
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -83,8 +83,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
83
83
|
const [start, end] = dailyOffpeakTime.split('-')
|
|
84
84
|
|
|
85
85
|
let wasOffpeak = null
|
|
86
|
-
|
|
87
|
-
const offPeakInterval = setInterval(() => {
|
|
86
|
+
setInterval(() => {
|
|
88
87
|
if (isTimeBetween(new Date(), start, end)) {
|
|
89
88
|
if (!wasOffpeak && global.gc) {
|
|
90
89
|
global.gc()
|
|
@@ -93,8 +92,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
93
92
|
} else {
|
|
94
93
|
wasOffpeak = false
|
|
95
94
|
}
|
|
96
|
-
}, 60e3)
|
|
97
|
-
destroyers.unshift(() => clearInterval(offPeakInterval))
|
|
95
|
+
}, 60e3).unref()
|
|
98
96
|
}
|
|
99
97
|
|
|
100
98
|
const cleanAppConfig = ({
|
|
@@ -290,6 +288,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
290
288
|
const lagMap = new LRUCache({ ttl: 10e3, max: 1024 })
|
|
291
289
|
|
|
292
290
|
const lagBC = new BroadcastChannel('nxt:lag')
|
|
291
|
+
lagBC.unref()
|
|
293
292
|
|
|
294
293
|
lagBC.onmessage = ({ data }) => {
|
|
295
294
|
lagMap.set(data.id, data.currentLag)
|
|
@@ -301,7 +300,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
301
300
|
}
|
|
302
301
|
})
|
|
303
302
|
|
|
304
|
-
|
|
303
|
+
setInterval(() => {
|
|
305
304
|
let currentLag = Math.max(0, histogram.mean / 1e6 - resolution)
|
|
306
305
|
if (Number.isNaN(currentLag)) {
|
|
307
306
|
currentLag = 0
|
|
@@ -323,12 +322,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
323
322
|
appLag = Math.max(appLag, lag ?? 0)
|
|
324
323
|
}
|
|
325
324
|
appLag$.next(appLag)
|
|
326
|
-
}, interval)
|
|
327
|
-
|
|
328
|
-
destroyers.unshift(() => {
|
|
329
|
-
clearInterval(lagInterval)
|
|
330
|
-
lagBC.close()
|
|
331
|
-
})
|
|
325
|
+
}, interval).unref()
|
|
332
326
|
|
|
333
327
|
toobusy = () => currentLag$.value > maxLag
|
|
334
328
|
toobusy.lag = () => currentLag$.value
|
|
@@ -480,6 +474,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
480
474
|
}
|
|
481
475
|
|
|
482
476
|
const memoryUsageBC = new BroadcastChannel('nxt:memoryUsage')
|
|
477
|
+
memoryUsageBC.unref()
|
|
483
478
|
|
|
484
479
|
let memoryUsageMap
|
|
485
480
|
if (isMainThread) {
|
|
@@ -489,14 +484,9 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
489
484
|
}
|
|
490
485
|
}
|
|
491
486
|
|
|
492
|
-
|
|
487
|
+
setInterval(() => {
|
|
493
488
|
memoryUsageBC.postMessage({ data: process.memoryUsage(), id: serviceWorkerId })
|
|
494
|
-
}, 1e3)
|
|
495
|
-
|
|
496
|
-
destroyers.unshift(() => {
|
|
497
|
-
clearInterval(memoryUsageInterval)
|
|
498
|
-
memoryUsageBC.close()
|
|
499
|
-
})
|
|
489
|
+
}, 1e3).unref()
|
|
500
490
|
|
|
501
491
|
const startTime = Date.now()
|
|
502
492
|
stats$ = stats$.pipe(
|
|
@@ -833,6 +823,8 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
833
823
|
// TODO (fix): What about cluster?
|
|
834
824
|
|
|
835
825
|
const inspectBC = new BroadcastChannel('nxt:inspect')
|
|
826
|
+
inspectBC.unref()
|
|
827
|
+
|
|
836
828
|
let inspectOpen = false
|
|
837
829
|
|
|
838
830
|
if (!isMainThread) {
|
|
@@ -975,8 +967,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
975
967
|
// TODO (fix): What about cluster?
|
|
976
968
|
|
|
977
969
|
const utilsBC = new BroadcastChannel('nxt:utils')
|
|
978
|
-
|
|
979
|
-
destroyers.unshift(() => utilsBC.close())
|
|
970
|
+
utilsBC.unref()
|
|
980
971
|
|
|
981
972
|
utilsBC.onmessage = ({ data }) => {
|
|
982
973
|
const { type } = data
|