Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest detecting open handle #22

Open
robross0606 opened this issue Jul 31, 2020 · 1 comment
Open

Jest detecting open handle #22

robross0606 opened this issue Jul 31, 2020 · 1 comment

Comments

@robross0606
Copy link

Jest is reporting that @echo-health/koa-prometheus-exporter has a handle left open after tests:

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  nan:test.DelayRequest

      11 | const OpentracingExtension = require('apollo-opentracing').default
      12 | const { initTracer /*, initTracerFromEnv, PrometheusMetricsFactory*/ } = require('jaeger-client')
    > 13 | const prometheus = require('@echo-health/koa-prometheus-exporter')
         |                    ^
      14 | const opentracing = require('opentracing')
      15 | 
      16 | const config = require('./config')

      at gcStats (node_modules/gc-stats/index.js:17:13)
      at node_modules/prometheus-gc-stats/index.js:56:7
      at Object.<anonymous> (node_modules/@echo-health/koa-prometheus-exporter/src/index.js:3:48)
      at Object.<anonymous> (src/server.js:13:20)

Waiting for the debugger to disconnect...
@robross0606
Copy link
Author

robross0606 commented Sep 24, 2020

From what I can tell, this is being caused by the index.js of the module calling client.collectDefaultMetrics(). This in turn calls setInterval(). So the code is kicking off a recurring timer just by requiring the module. The handle for the timer is never returned so there's no way to control it from outside the module. This is an anti-pattern. Instead, export some way for the user to control when (if?) they want to start this timer and provide the handle for the timer back to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant