PM2 Scheduled Cron Jobs Not Fetching Data from API after Update
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
What's going wrong?
I've been using PM2 to manage my Node.js applications for over a year. These applications fetch data from a REST API every 20 minutes, five days a week, and save the results to a database, including the date and time of the fetch.
This setup worked perfectly until a few months ago when I updated PM2 to a new version (unfortunately, I don't recall the exact version). After the update, the cron jobs still execute as scheduled, but the API's response is unexpectedly empty, even though the same request URL returns over 100 objects when tested through Postman.
Here are some steps I've taken to debug:
-
Verified the request URL by logging it and adjusting the cron schedule to hourly. The URL includes a lastModifiedDate parameter, which is dynamically obtained from the database to fetch new data.
-
Confirmed that manually reloading the PM2 process using pm2 reload somehow causes the application to receive the expected data from the API. Despite upgrading to PM2 version 5.3.1, the issue persists.
Here are some additional details that might be relevant: -
The Node.js and PM2 configurations have not changed, aside from the PM2 update. No errors are logged by the application or PM2, making this issue particularly puzzling.
-
I'm stumped as to why scheduled executions fail to fetch data correctly but manually reloading the process works. Has anyone encountered a similar issue or can offer insights into potential causes or solutions?
Additional Information:
PM2 version: 5.3.1
Node.js version: v20.2.0
Attempted Solutions:
- Verifying network connectivity and API rate limits
- Checking for changes in the API's behavior or data structure
I appreciate any help or suggestions you can provide. Thank you!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report names PM2 5.3.1 and Node.js v20.2.0 but provides no repository file, test, or entry point. Start by reproducing the scheduled API request versus a pm2 reload, then document a confirmed cause and regression coverage as the definition of done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100