Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
under-pressure
Advanced tools
Measure process load with automatic handling of 'Service Unavailable' plugin for Fastify.
Measure process load with automatic handling of "Service Unavailable" plugin for Fastify.
It can check maxEventLoopDelay
, maxHeapUsedBytes
and maxRssBytes
values.
Fastify ^1.1.0 .
npm i under-pressure --save
Require the plugin and register it into the Fastify instance.
const fastify = require('fastify')()
fastify.register(require('under-pressure'), {
maxEventLoopDelay: 1000,
maxHeapUsedBytes: 100000000,
maxRssBytes: 100000000
})
fastify.get('/', (req, reply) => {
reply.send({ hello: 'world'})
})
fastify.listen(3000, err => {
if (err) throw err
console.log(`server listening on ${fastify.server.address().port}`)
})
under-pressure
will automatically handle for you the Service Unavailable
error once one of the thresholds has been reached.
You can configure the error message and the Retry-After
header.
fastify.register(require('under-pressure'), {
maxEventLoopDelay: 1000,
message: 'Under pressure!',
retryAfter: 50
})
The default value for maxEventLoopDelay
, maxHeapUsedBytes
and maxRssBytes
is 0
.
If the value is 0
the check will not be performed.
Thanks to the encapsulation model of Fastify, you can selectively use this plugin in some subset of routes or even with different thresholds in different plugins.
memoryUsage
This plugin also exposes a function that will tell you the current values of heapUsed
, rssBytes
and eventLoopDelay
.
console.log(fastify.memoryUsage())
If needed you can pass { exposeStatusRoute: true }
and under-pressure
will expose a /status
route for you that sends back a { status: 'ok' }
object. This can be useful if you need to attach the server to an ELB on AWS for example.
If you need the change the exposed route path, you can pass { exposeStatusRoute: '/alive' }
options.
This project is kindly sponsored by LetzDoIt.
Licensed under MIT.
FAQs
`under-pressure@6.1.0` has been deprecated. Please use `@fastify/under-pressure@7.0.0` instead.
The npm package under-pressure receives a total of 7,800 weekly downloads. As such, under-pressure popularity was classified as popular.
We found that under-pressure demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 17 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.