You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 27, 2025. It is now read-only.
I am integrating Pulse into my Fastify 5.x application and writing a spec to test the integration. The test itself runs as expected, but I am encountering the following warning message when Jest completes execution:
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
It appears that worker.stop() does not properly clean up the worker after the test completes, leading to Jest detecting an open handle.
worker = new Pulse(workerConfig);
await worker.start();
Stop the worker and in-memory MongoDB in afterAll:
await worker.stop();
await mongoServer.stop();
Run the test suite with Jest.
Expected Behavior
Jest should exit cleanly after tests complete.
worker.stop() should correctly clean up all resources.
Actual Behavior
Jest does not exit after tests complete.
The warning suggests open asynchronous operations are still running, possibly from Pulse's internal processes.
Possible Solutions Explored
Running Jest with --detectOpenHandles confirms the issue is related to Pulse.
Ensured worker.stop() is called in afterAll, but it does not resolve the issue.
Environment
Dependency
Version
Fastify
5.x
Pulse
@pulsecron/pulse latest
Jest
x.x.x
Node.js
x.x.x
MongoMemoryServer
latest
Additional Context
Would appreciate any guidance on whether Pulse requires additional cleanup beyond worker.stop() or if there is an open issue regarding resource cleanup.
Thank you! 🙏
Here is my full spec
//tests/pulse.spec.ts/* eslint-disable @typescript-eslint/no-explicit-any */importPulse,{Job,PulseConfig}from"@pulsecron/pulse";import{MongoMemoryServer}from"mongodb-memory-server";describe("worker",()=>{letworker: Pulse;letmongoServer: MongoMemoryServer;beforeAll(async()=>{// Start an in-memory MongoDB servermongoServer=awaitMongoMemoryServer.create();constmongoURI=mongoServer.getUri();console.log("Mongo URI: ",mongoURI);constworkerConfig: PulseConfig={db: {address: mongoURI,collection: "jobs_test"},processEvery: "2 seconds",maxConcurrency: 4,disableAutoIndex: false,defaultConcurrency: 5,// Max 5 jobs running at the same time};worker=newPulse(workerConfig);awaitworker.start();});afterAll(async()=>{console.log("Stopping worker");awaitworker.stop();console.log("Stopping mongoServer");awaitmongoServer.stop();});it("should have a default concurrency of 5",async()=>{worker.define("with_arg_job",async(job: Job)=>{console.info("Executing job: with_arg_job",job.attrs.data);});worker.define("without_arg_job",async()=>{console.info("Executing job: without_arg_job");});awaitworker.create("with_arg_job",{email: "test@pulse.org"}).save();awaitworker.create("without_arg_job",{}).save();});});
Description
I am integrating Pulse into my Fastify 5.x application and writing a spec to test the integration. The test itself runs as expected, but I am encountering the following warning message when Jest completes execution:
It appears that
worker.stop()does not properly clean up the worker after the test completes, leading to Jest detecting an open handle.Steps to Reproduce
beforeAll:afterAll:Expected Behavior
worker.stop()should correctly clean up all resources.Actual Behavior
Possible Solutions Explored
--detectOpenHandlesconfirms the issue is related to Pulse.worker.stop()is called inafterAll, but it does not resolve the issue.Environment
Additional Context
Would appreciate any guidance on whether Pulse requires additional cleanup beyond
worker.stop()or if there is an open issue regarding resource cleanup.Thank you! 🙏
Here is my full spec
Test output