Express middleware starts heap profiling but does not stop it
lizthegrey opened this issue · 2 comments
lizthegrey commented
if, for instance, in a testsuite, app()
entry point is called once for each testcase, a new express is provisioned (correctly), and middleware/handlers attempt to register each time.
but the pyroscope middleware is not idempotent -- if heap profiling is already on, it'll attempt to enable it again and crash. better to either register a shutdown hook, or to not attempt to enable heap profiling a second time if called twice in same nodejs runtime.
lizthegrey commented
Thanks @shaleynikov. One more test to add, if you wouldn't mind (but I'm confident your fix does fix our testsuite problem which is this one):
const app = express();
app.use(expressMiddleware());
const app2 = express();
app2.use(expressMiddleware());
shaleynikov commented
@lizthegrey added!