Skip to content

Conversation

Shitanshukumar607
Copy link
Contributor

Description

Implemented a simple keep-alive solution using node-cron to send requests every 10 minutes, preventing Render free tier from idling and improving user experience by reducing cold start delays

Related Issue

Fixes #51

Motivation and Context

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Enhancement (improvement to an existing feature)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Test (adds or updates tests only)
  • Documentation (non-code change)

How Has This Been Tested?

Screenshots (if applicable):

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@Copilot Copilot AI review requested due to automatic review settings October 2, 2025 17:15
Copy link

netlify bot commented Oct 2, 2025

Deploy Preview for paisable ready!

Name Link
🔨 Latest commit 35f6045
🔍 Latest deploy log https://app.netlify.com/projects/paisable/deploys/68e3fef049f1120008925bd7
😎 Deploy Preview https://deploy-preview-61--paisable.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 95
Accessibility: 100
Best Practices: 100
SEO: 91
PWA: 70
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a keep-alive mechanism to prevent Render free tier from idling by adding a cron job that pings the external service every 10 minutes.

  • Adds node-cron and axios dependencies for scheduling and HTTP requests
  • Implements a cron job that runs every 10 minutes to send keep-alive pings
  • Includes basic error handling with console logging for ping status

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 51 to 52
try {
await axios.get("https://paisable.onrender.com");
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded URL should be moved to an environment variable to improve maintainability and allow different URLs for different environments.

Suggested change
try {
await axios.get("https://paisable.onrender.com");
const keepAliveUrl = process.env.KEEP_ALIVE_URL;
if (!keepAliveUrl) {
console.error("KEEP_ALIVE_URL environment variable is not set. Skipping keep-alive ping.");
return;
}
try {
await axios.get(keepAliveUrl);

Copilot uses AI. Check for mistakes.

Comment on lines 50 to 57
cron.schedule("*/10 * * * *", async () => {
try {
await axios.get("https://paisable.onrender.com");
console.log("Keep-alive ping sent ✅");
} catch (error) {
console.error("Keep-alive failed ❌", error.message);
}
});
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a timeout to the axios request to prevent the cron job from hanging indefinitely if the external service is unresponsive.

Copilot uses AI. Check for mistakes.

Copy link
Member

@archa8 archa8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shitanshukumar607 Thank you for opening the PR.
Please remove the backend API URL from the code and put it in the .env file and I see there are manual changes to the lockfile (package-lock.json) too, you have removed the "dev": true field from some packages. It might cause the lockfile to break. Please revert those changes so that the lockfile is consistent

@Copilot Copilot AI review requested due to automatic review settings October 6, 2025 10:19
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • backend/package-lock.json: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Shitanshukumar607
Copy link
Contributor Author

@archa8 i have put backend API URL in the env and about the changes in package-lock.json, those were not manual changes but caused by npm itself when installing other dependecies. I can ensure the lock file will not break

Copy link
Member

@archa8 archa8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@archa8 archa8 merged commit 9a4301f into Code-A2Z:master Oct 6, 2025
4 checks passed
@Shitanshukumar607
Copy link
Contributor Author

@archa8 Thanks for merging the PR, can you also add the hacktober fest labels? Thanks

@Shitanshukumar607
Copy link
Contributor Author

@archa8 please add hacktober fest labels

@archa8
Copy link
Member

archa8 commented Oct 7, 2025

@archa8 please add hacktober fest labels

Hey @Shitanshukumar607, Hacktoberfest will automatically count this as your contribution, it doesn't need separate labels.

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

Successfully merging this pull request may close these issues.

bug: The backend sleeps after inactivity

2 participants