Skip to content

PM2 Scheduled Cron Jobs Not Fetching Data from API after Update #5757

@melroy-bsk

Description

@melroy-bsk

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!

I had asked this question stack overflow as well

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions