under-pressure
Advanced tools
Comparing version 5.7.0 to 5.8.0
@@ -141,2 +141,3 @@ 'use strict' | ||
eventLoopDelay = Math.max(0, histogram.mean / 1e6 - resolution) | ||
if (Number.isNaN(eventLoopDelay)) eventLoopDelay = Infinity | ||
histogram.reset() | ||
@@ -143,0 +144,0 @@ } else { |
{ | ||
"name": "under-pressure", | ||
"version": "5.7.0", | ||
"version": "5.8.0", | ||
"description": "Measure process load with automatic handling of 'Service Unavailable' plugin for Fastify.", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@types/node": "^15.0.1", | ||
"@types/node": "^16.3.1", | ||
"fastify": "^3.0.0", | ||
@@ -41,3 +41,3 @@ "pre-commit": "^1.2.2", | ||
"standard": "^16.0.0", | ||
"tap": "^15.0.3", | ||
"tap": "^15.0.10", | ||
"tsd": "^0.14.0", | ||
@@ -44,0 +44,0 @@ "typescript": "^4.0.3" |
@@ -237,1 +237,46 @@ 'use strict' | ||
}) | ||
test('event loop delay (NaN)', { skip: !isSupportedVersion }, t => { | ||
t.plan(5) | ||
const mockedUnderPressure = t.mock('../index', { | ||
perf_hooks: { | ||
monitorEventLoopDelay: () => ({ | ||
enable: () => { }, | ||
reset: () => { }, | ||
mean: NaN | ||
}), | ||
performance: { | ||
eventLoopUtilization: () => { } | ||
} | ||
} | ||
}) | ||
const fastify = Fastify() | ||
fastify.register(mockedUnderPressure, { | ||
maxEventLoopDelay: 1000, | ||
pressureHandler: (req, rep, type, value) => { | ||
t.equal(type, underPressure.TYPE_EVENT_LOOP_DELAY) | ||
t.equal(value, Infinity) | ||
rep.send('B') | ||
} | ||
}) | ||
fastify.get('/', async (req, rep) => rep.send('A')) | ||
fastify.listen(0, (err, address) => { | ||
t.error(err) | ||
fastify.server.unref() | ||
process.nextTick(() => block(1000)) | ||
sget({ | ||
method: 'GET', | ||
url: address | ||
}, (err, response, body) => { | ||
t.error(err) | ||
t.equal(body.toString(), 'B') | ||
fastify.close() | ||
}) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49084
1271