@nxtedition/lib 19.8.17 → 19.8.19
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 +3 -4
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -22,6 +22,7 @@ import { makeTrace } from './trace.js'
|
|
|
22
22
|
import compose from 'koa-compose'
|
|
23
23
|
import { createServer } from './http.js'
|
|
24
24
|
import { json } from 'node:stream/consumers'
|
|
25
|
+
import { monitorEventLoopDelay } from 'node:perf_hooks'
|
|
25
26
|
|
|
26
27
|
export function makeApp(appConfig, onTerminate) {
|
|
27
28
|
let ds
|
|
@@ -218,8 +219,6 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
218
219
|
let toobusy
|
|
219
220
|
|
|
220
221
|
if (appConfig.toobusy) {
|
|
221
|
-
const { monitorEventLoopDelay } = require('node:perf_hooks')
|
|
222
|
-
|
|
223
222
|
const resolution = 10
|
|
224
223
|
const interval = 500
|
|
225
224
|
const maxLag = 70
|
|
@@ -232,13 +231,13 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
232
231
|
setInterval(() => {
|
|
233
232
|
currentLag = Math.max(0, histogram.mean / 1e6 - resolution)
|
|
234
233
|
if (Number.isNaN(currentLag)) {
|
|
235
|
-
currentLag =
|
|
234
|
+
currentLag = null
|
|
236
235
|
}
|
|
237
236
|
histogram.reset()
|
|
238
237
|
|
|
239
238
|
if (currentLag > 1e3) {
|
|
240
239
|
logger?.error({ currentLag }, 'lag')
|
|
241
|
-
} else {
|
|
240
|
+
} else if (currentLag > maxLag) {
|
|
242
241
|
logger?.warn({ currentLag }, 'lag')
|
|
243
242
|
}
|
|
244
243
|
}, interval).unref()
|