Giter Site home page Giter Site logo

under-pressure's Introduction

@fastify/under-pressure

CI NPM version js-standard-style

Measure process load with automatic handling of "Service Unavailable" plugin for Fastify. It can check maxEventLoopDelay, maxHeapUsedBytes, maxRssBytes and maxEventLoopUtilization values. You can also specify a custom health check, to verify the status of external resources.

Requirements

Fastify ^4.0.0. Please refer to this branch and related versions for Fastify ^1.1.0 compatibility.

Install

npm i @fastify/under-pressure

Usage

Require the plugin and register it into the Fastify instance.

const fastify = require('fastify')()

fastify.register(require('@fastify/under-pressure'), {
  maxEventLoopDelay: 1000,
  maxHeapUsedBytes: 100000000,
  maxRssBytes: 100000000,
  maxEventLoopUtilization:0.98
})

fastify.get('/', (req, reply) => {
  if (fastify.isUnderPressure()) {
    // skip complex computation
  }
  reply.send({ hello: 'world'})
})

fastify.listen({ port: 3000 }, err => {
  if (err) throw err
  console.log(`server listening on ${fastify.server.address().port}`)
})

@fastify/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('@fastify/under-pressure'), {
  maxEventLoopDelay: 1000,
  message: 'Under pressure!',
  retryAfter: 50
})

You can also configure custom Error instance @fastify/under-pressure will throw.

  class CustomError extends Error {
    constructor () {
      super('Custom error message')
      Error.captureStackTrace(this, CustomError)
    }
  }

  fastify.register(require('@fastify/under-pressure'), {
  maxEventLoopDelay: 1000,
  customError: CustomError
})

The default value for maxEventLoopDelay, maxHeapUsedBytes, maxRssBytes and maxEventLoopUtilization is 0. If the value is 0 the check will not be performed.

Since eventLoopUtilization is only available in Node version 14.0.0 and 12.19.0 the check will be disabled in other versions.

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, eventLoopDelay and eventLoopUtilized.

console.log(fastify.memoryUsage())

Pressure Handler

You can provide a pressure handler in the options to handle the pressure errors. The advantage is that you know why the error occurred. Moreover, the request can be handled as if nothing happened.

const fastify = require('fastify')()
const underPressure = require('@fastify/under-pressure')()

fastify.register(underPressure, {
  maxHeapUsedBytes: 100000000,
  maxRssBytes: 100000000,
  pressureHandler: (req, rep, type, value) => {
    if (type === underPressure.TYPE_HEAP_USED_BYTES) {
      fastify.log.warn(`too many heap bytes used: ${value}`)
    } else if (type === underPressure.TYPE_RSS_BYTES) {
      fastify.log.warn(`too many rss bytes used: ${value}`)
    }

    rep.send('out of memory') // if you omit this line, the request will be handled normally
  }
})

It is possible as well to return a Promise that will call reply.send (or something else).

fastify.register(underPressure, {
  maxHeapUsedBytes: 100000000,
  pressureHandler: (req, rep, type, value) => {
    return getPromise().then(() => reply.send({hello: 'world'}))
  }
})

Any other return value than a promise or nullish will be sent to client with reply.send.

Status route

If needed you can pass { exposeStatusRoute: true } and @fastify/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.

To configure the endpoint more specifically you can pass an object. This consists of

  • routeOpts - Any Fastify route options except schema
  • routeSchemaOpts - As per the Fastify route options, an object containing the schema for request
  • routeResponseSchemaOpts - An object containing the schema for additional response items to be merged with the default response schema, see below
  • url - The URL to expose the status route on
fastify.register(require('@fastify/under-pressure'), {
  maxEventLoopDelay: 1000,
  exposeStatusRoute: {
    routeOpts: {
      logLevel: 'debug',
      config: {
        someAttr: 'value'
      }
    },
    routeSchemaOpts: { // If you also want to set a custom route schema
      hide: true
    },
    url: '/alive' // If you also want to set a custom route path and pass options
  }
})

The above example will set the logLevel value for the /alive route to be debug.

If you need to return other information in the response, you can return an object from the healthCheck function (see next paragraph) and use the routeResponseSchemaOpts property to describe your custom response schema (note: status will always be present in the response)

fastify.register(underPressure, {
  ...
  exposeStatusRoute: {
    routeResponseSchemaOpts: {
      extraValue: { type: 'string' },
      metrics: {
        type: 'object',
        properties: {
          eventLoopDelay: { type: 'number' },
          rssBytes: { type: 'number' },
          heapUsed: { type: 'number' },
          eventLoopUtilized: { type: 'number' },
        },
      },
      // ...
    }
  },
  healthCheck: async (fastifyInstance) => {
    return {
      extraValue: await getExtraValue(),
      metrics: fastifyInstance.memoryUsage(),
      // ...
    }
  },
}

Custom health checks

If needed you can pass a custom healthCheck property, which is an async function, and @fastify/under-pressure will allow you to check the status of other components of your service.

This function should return a promise that resolves to a boolean value or to an object. The healthCheck function can be called either:

  • every X milliseconds, the time can be configured with the healthCheckInterval option.
  • every time the status route is called, if exposeStatusRoute is set to true.

By default when this function is supplied your service health is considered unhealthy, until it has started to return true.

const fastify = require('fastify')()

fastify.register(require('@fastify/under-pressure'), {
  healthCheck: async function (fastifyInstance) {
    // do some magic to check if your db connection is healthy, etc...
    return true
  },
  healthCheckInterval: 500
})

Sample interval

You can set a custom value for sampling the metrics returned by memoryUsage using the sampleInterval option, which accepts a number that represents the interval in milliseconds.

The default value is different depending on which Node version is used. In version 8 and 10 it is 5, while on version 11.10.0 and up it is 1000. This difference is because from version 11.10.0 the event loop delay can be sampled with monitorEventLoopDelay and this allows to increase the interval value.

const fastify = require('fastify')()

fastify.register(require('@fastify/under-pressure'), {
  sampleInterval: <your custom sample interval in ms>
})

Additional information

setTimeout vs setInterval

Under the hood the @fastify/under-pressure uses the setTimeout method to perform its polling checks. The choice is based on the fact that we do not want to add additional pressure to the system.

In fact, it is known that setInterval will call repeatedly at the scheduled time regardless of whether the previous call ended or not, and if the server is already under load, this will likely increase the problem, because those setInterval calls will start piling up. setTimeout, on the other hand, is called only once and does not cause the mentioned problem.

One note to consider is that because the two methods are not identical, the timer function is not guaranteed to run at exactly the same rate when the system is under pressure or running a long-running process.

Acknowledgements

This project is kindly sponsored by LetzDoIt.

License

Licensed under MIT.

under-pressure's People

Contributors

cemremengu avatar climba03003 avatar davideroffo avatar delvedor avatar dependabot-preview[bot] avatar dependabot[bot] avatar dnlup avatar eomm avatar fdawgs avatar frikille avatar github-actions[bot] avatar glentiki avatar greenkeeper[bot] avatar jelenkee avatar karlos1337 avatar koderfunk avatar lependu avatar luke88jones avatar mcollina avatar mslabik avatar muya avatar p16 avatar rafaelgss avatar salmanm avatar sandromartiniynap avatar serayaeryn avatar smartiniongithub avatar sujeshthekkepatt avatar uzlopak avatar zekth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

under-pressure's Issues

Histogram returning NaN

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

3.20.1

Plugin version

5.7.0

Node.js version

14.17.1

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

10.14.6 (Mojave)

Description

In some cases, on very high load (or some time-consuming sync actions) the node's histogram.mean can be NaN and produce a false-negative condition that does not trigger under-pressure. In extreme cases, it can lead to node process being unresponsive.

Histogram {
  min: 9223372036854776000,
  max: 0,
  mean: NaN,
  exceeds: 0,
  stddev: NaN,
  percentiles: SafeMap(1) [Map] { 100 => 0 }
}

The min value however is always present and could be used in the comparison instead. The second option is to use Infinity to compare

Steps to Reproduce

Both scenarios were reproduced using autocannon:

a) Time consuming synchronous action used in fastify route handler, e.g.:

function sleep(ms) {
    const start = new Date().getTime();
    const expire = start + ms;
    while (new Date().getTime() < expire) { }
}

b) Big amount of connections to real-life service (500 or more in our case)

Expected Behavior

under-pressure being calculated properly and triggered

Ambiguous supported versions documentation

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

x.xx

Plugin version

x.xx

Node.js version

x.xx

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

xxx

Description

Currently documentation states this:
///
Since eventLoopUtilization is only available in Node version 14.0.0 and 12.19.0 the check will be disabled in other versions.
///
I assume it actually works in 14.0.0+, not just that specific version, but documentation claims otherwise. It would be helpful to improve wording to make the intent clearer.

Steps to Reproduce

Documentation issue

Expected Behavior

///
Since eventLoopUtilization is only available in Node versions 12.19.0, 14.0.0, and newer, the check will be disabled in other versions.
///

An in-range update of tap is breaking the build 🚨

Version 10.7.3 of tap was just published.

Branch Build failing 🚨
Dependency tap
Current Version 10.7.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

tap is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 5 commits.

  • 104728e v10.7.3
  • 352878f Update deps
  • 13f2ca2 Fix missing β€œnot” in default message for strictNotSame
  • 067dc57 node can be called nodejs
  • a335bc4 fixed punctuation in readme

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of tap is breaking the build 🚨

The devDependency tap was updated from 12.4.0 to 12.4.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

tap is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 7 commits.

  • c17e6db 12.4.1
  • 88eb85b Ignore timers in _getActiveHandles reporting
  • 58699d7 remove unused js-yaml from lib/tap.js
  • 4621be8 node 11 no longer blocks process.reallyExit
  • 74e4671 Add node 11 to travis
  • b074a1a Don't use bluebird
  • e8fb7df update nyc to v13

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Use custom Error instance

πŸš€ Feature Proposal

Custom error thrown & exported from lib. Allow to override Error instance.

Motivation

It's hard to distinguish if error comes from plugin, the only way is to check string message.

Example

In fastify error handler

const { UnderPressureError }  = require('under-pressure'); 

const errorHandler = async (err, req, reply) => {
    if (err instanceof UnderPressureError) {
        return sendCustomError(reply, 'Service is under pressure.', E_10000_GENERIC, SERVICE_UNAVAILABLE);
    }
}

consider setTimeout instead of setInterval for polling

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

setInterval will repeatedly call at the scheduled time whether or not the previous call has finished. if the server is already under load, this will likely add to the problem, because those setInterval calls will start to stack. i imagine this would be especially bad in node v8 with setInterval(..., 5ms).

for node >= v10.2.0, using setTimeout and timer.refresh would avoid this issue. i swapped it in and tests pass in node v14, at least:

  const timer = setTimeout(() => {
    updateMemoryUsage()
    timer.refresh()
  }, sampleInterval)

Custom function for process metrics

πŸš€ Feature Proposal

Expose a custom function to gather process metrics.

Motivation

There are cases in which there's already a module/library that monitors process metrics, for example, to report to statsd/prometeus and similar platforms. This would allow reusing those modules for a similar task.

Example

fastify.register(require('under-pressure'), {
  maxEventLoopUtilization:0.98,
  // This custom function will be bound to the fastify instance
  usage() {
    const { eventLoopUtilization } = this.customMetrics
    return { eventLoopUtilization }
 }
})

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}`)
})

Notes

There are a lot of details to figure out here, like defining a way to make sure the object returned by the custom usage function is safe to use (i.e., it defines all the properties needed), but I just wanted to start a discussion to understand if it's something this plugin could provide.

Setting logLevel option for status route has no effect

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

3.28.0

Plugin version

5.8.1

Node.js version

18.0.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

10.β€Ž06.β€Ž2020

Description

.register(underPressurePligin, {
        exposeStatusRoute: {
            routeOpts: {
                logLevel: 'debug',
            },
            url: '/alive',
        },
        healthCheck: async function (fastifyInstance) {
            // do some magic to check if your db connection is healthy, etc...
            return true;
        },
    })

the contents of the log after executing the request

{
    "level": "info",
    "time": 1651439672804,
    "instance": "unknown:3000",
    "version": "1.0.0",
    "reqId": "req-1",
    "req": {
        "method": "GET",
        "url": "/alive",
        "path": "/alive",
        "parameters": {},
    },
    "msg": "incoming request"
}

log level is info instead of debug

Steps to Reproduce

setup server with under-pressure plugin with above config an run

Expected Behavior

expected loglevel for status route to be as defined in config

An in-range update of tap is breaking the build 🚨

The devDependency tap was updated from 12.5.2 to 12.5.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

tap is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 2 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @types/node is breaking the build 🚨

The devDependency @types/node was updated from 12.12.8 to 12.12.9.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Breaking fastify server!

πŸ› Bug Report

Breaking fastify server!

The main purpose of [under-pressure][1] plugin is to protect the server against the high load. I created a fake load using [autocannon][2] and the server suddenly starts throwing this error:

<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 00007FF7D342A9AC]
Security context: 0x01b3e02408d1 <JSObject>
    1: _write [000001EBE7CBA7B1] [_stream_transform.js:~169] [pc=000002737CBBD07D](this=0x02fe03573099 <LineStream map = 00000149AA79E209>,0x00f819d83789 <Uint8Array map = 000002F9BBE3F279>,0x00c0496035d9 <String[#6]: buffer>,0x02fe03575639 <JSBoundFunction (BoundTargetFunction 000003C5D37BC781)>)        
    2: ondata [000002FE03577FC9] [_stream_readable.js:~712]...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF7D28A363F napi_wrap+128063
 2: 00007FF7D2842836 v8::base::CPU::has_sse+35142
 3: 00007FF7D28434F6 v8::base::CPU::has_sse+38406
 4: 00007FF7D3059F4E v8::Isolate::ReportExternalAllocationLimitReached+94
 5: 00007FF7D3042021 v8::SharedArrayBuffer::Externalize+833
 6: 00007FF7D2F0E57C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1436
 7: 00007FF7D2F197D0 v8::internal::Heap::ProtectUnprotectedMemoryChunks+1312
 8: 00007FF7D2F162F4 v8::internal::Heap::PageFlagsAreConsistent+3204
 9: 00007FF7D2F0BB13 v8::internal::Heap::CollectGarbage+1283
10: 00007FF7D2F0A184 v8::internal::Heap::AddRetainedMap+2452
11: 00007FF7D2F31E1F v8::internal::Factory::NewRawTwoByteString+95
12: 00007FF7D2F349CB v8::internal::Factory::NewStringFromUtf8+187
13: 00007FF7D305681A v8::String::NewFromUtf8+298
14: 00007FF7D27A9ABF node::tracing::TraceEventHelper::SetAgent+40751
15: 00007FF7D285A46D v8::internal::Malloced::operator delete+1661
16: 00007FF7D342A9AC v8::internal::SetupIsolateDelegate::SetupHeap+45852
17: 000002737CBBD07D

To Reproduce

Steps to reproduce the behavior:

fastify.register(require('under-pressure') , {
    maxEventLoopDelay: 0,
    maxHeapUsedBytes: 0,
    maxRssBytes: 0
})

console.log(fastify.memoryUsage())

Expected behavior

The very fastify plugin which is supposed to protect against load is breaking the fastify server, need some help with another plugin or some other way to implement load protection

Your Environment

  • node version: v12.16.1
  • fastify version: ^3.4.1
  • os: Windows 10
  • npm: 6.13.4

Cross posted on Stackoverflow: https://stackoverflow.com/q/64137079/2404470

An in-range update of tap is breaking the build 🚨

The devDependency tap was updated from 12.5.0 to 12.5.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

tap is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 4 commits.

  • d03f383 12.5.1
  • 2816d28 Ignore esm in stack output
  • 7daf018 do not run browser test in node v6
  • a51cc6f run test: load tap from full module location

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Make new release

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

Would be nice to release 4023ba6 and 13e9781. Installing latest pulled in @fastify/error@2 into the lockfile - all other @fastify/* deps in our project is using v3 πŸ˜€

bug when setting custom error handler

          I had a second look at it seems we have bugs in that part, before you even touched it.

schema: Object.assign({}, opts.exposeStatusRoute.routeSchemaOpts, {

When opts.exposeStatusRoute.routeSchemaOpts is in Object.assign before our changes, than it means we can not overwrite the error statuscodes.

The same here:

opts.exposeStatusRoute.routeResponseSchemaOpts

We could set a custom error handler like this:

    fastify.setErrorHandler((err, request, reply, done) => {
      reply.status(err.statusCode)
        .send({
          code: err.code,
          message: err.message
        })
      done()
    })

a potential unit test would be:

test('check error handler', async t => {
  t.plan(1)
  const fastify = Fastify({ exposeStatusRoute: true })

  fastify.register(underPressure, {
    healthCheck: () => {
      throw new Error('Arbitrary Error')
    },    
    exposeStatusRoute: {
      routeOpts: {
        logLevel: 'silent'
      }
    }
  })

  t.equal((await fastify.inject().get('/').end()).body, '{"code":"FST_UNDER_PRESSURE","message":"Service Unavailable"}')
})

Originally posted by @Uzlopak in #198 (comment)

Allow passthrough of `exposeHeadRoute` route param

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

πŸš€ Feature Proposal

Expand the plugin's configuration options to allow the Fastify route option for exposeHeadRoute to be set.

Happy to do the work for this if you think it's a good idea.

Motivation

Kubernetes needs an endpoint that responds with a 2XX or 3XX HTTP status code to check the health of the deployed service (ref). I think it would be great to be able to re-use the under pressure endpoint for this functionality but currently this isn't possible as the Kubernetes check is a HEAD request.

Example

fastify.register(require('under-pressure'), {
  maxEventLoopDelay: 1000,
  exposeStatusRoute: {
    routeOpts: {
      exposeHeadRoute: true,
      logLevel: 'debug',
      config: {
        someAttr: 'value'
      }
    },
    routeSchemaOpts: { // If you also want to set a custom route schema
      hide: true
    },
    url: '/alive' // If you also want to set a custom route path and pass options
  }
})

An in-range update of fastify-plugin is breaking the build 🚨

The dependency fastify-plugin was updated from 1.4.0 to 1.5.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

fastify-plugin is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v1.5.0
  • support for transpiled modules #61
Commits

The new version differs by 3 commits.

  • e2d6f1f Bumped v1.5.0
  • caff3e9 fn.default check for transpiled modules (#61)
  • 31708bb Add tests for dependency graph checking (#58)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

How to find out in a custom healthCheck whether the service is under pressure?

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

Is custom healthCheck called after checking under pressure?
If no - we need In addition to the Db and Redis state, to know if the service is under pressure in order to form the correct answer.

Additional route options are not passed when exposing status route

πŸ› Bug Report

When attempting to change the log level of the status route, the option is not passed along when under-pressure builds the route.

To Reproduce

Steps to reproduce the behavior:

fastify.register(require('under-pressure'), {
      maxEventLoopDelay: 1000,
      maxHeapUsedBytes: 100000000,
      maxRssBytes: 100000000,
      exposeStatusRoute: true,
      logLevel: 'silent'
    });

When hitting the ./status route I can still see the request and response logs, which will clutter up the log files.

Expected behavior

when setting options for the plugin, they should be forwarded to the route registration in under-pressure.

Your Environment

  • node version: 8
  • fastify version: ^2.10.0
  • under-pressure version: ^3.1.0

I'm happy to submit a PR to resolve the issue if required.

Allow custom response from healthCheck function

πŸš€ Feature Proposal

Allow healthCheck to return a custom response that will override the default { status: 'ok'} response.

Motivation

Sometime the "status" or "health" endpoints are used to return multiple informations about the system status: db connection, external services, etc. .

Example

In the above scenario, having just a { status: 'ok' } may not be enough.

ie:

{
  status: 'ok',
  db: 'ok',
  externalService: 'ko',
  externalService2: 'ok',
  ...
}

An in-range update of fastify is breaking the build 🚨

The devDependency fastify was updated from 2.0.0 to 2.0.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

fastify is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v2.0.1

Fixes:

  • fix: unused shared schema to serializer - #1496

Docs:

  • Docs/fluent schema - #1485
  • add fastify-405 plugin - #1501
  • Updated benchmarks - #1497
  • Added fastify-influxdb to Community Plugins - #1472
  • Updated LTS.md - #1477

Internals:

  • refactor: remove unnecessary condition - #1505

Dependencies:

  • chore(package): update fast-json-stringify to version 1.11.2 - #1500
  • Update deps - #1493
Commits

The new version differs by 11 commits.

  • b456013 Bumped v2.0.1
  • b2bdfee refactor: remove unnecessary condition (#1505)
  • 3626ca9 add: @eomm as contributor (#1507)
  • 29a77b9 Docs/fluent schema (#1485)
  • 9398dfa fix: unused shared schema to serializer (#1496)
  • 563926f add fastify-405 plugin (#1501)
  • cf7a096 chore(package): update fast-json-stringify to version 1.11.2 (#1500)
  • 25ee251 Updated benchmarks (#1497)
  • c24b14a Update deps (#1493)
  • 0ff444b Added fastify-influxdb to Community Plugins (#1472)
  • 956c593 Updated LTS.md (#1477)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.