Skip to content

fix(push): don't delay overdue down checks after restart (#6866)#7067

Open
dharunashokkumar wants to merge 5 commits intolouislam:masterfrom
dharunashokkumar:fix/push-down-timeout-6866
Open

fix(push): don't delay overdue down checks after restart (#6866)#7067
dharunashokkumar wants to merge 5 commits intolouislam:masterfrom
dharunashokkumar:fix/push-down-timeout-6866

Conversation

@dharunashokkumar
Copy link
Copy Markdown
Contributor

Summary

In this pull request, the following changes are made:

Please follow this checklist to avoid unnecessary back and forth (click to expand)
  • ⚠️ If there are Breaking change (a fix or feature that alters existing functionality in a way that could cause issues) I have called them out
  • 🧠 I have disclosed any use of LLMs/AI in this contribution and reviewed all generated content.
    I understand that I am responsible for and able to explain every line of code I submit.
  • 🔍 Any UI changes adhere to visual style of this project.
  • 🛠️ I have self-reviewed and self-tested my code to ensure it works as expected.
  • 📝 I have commented my code, especially in hard-to-understand areas (e.g., using JSDoc for methods).
  • 🤖 I added or updated automated tests where appropriate.
  • 📄 Documentation updates are included (if applicable).
  • 🧰 Dependency updates are listed and explained.
  • ⚠️ CI passes and is green.

Screenshots for Visual Changes

  • UI Modifications: Highlight any changes made to the user interface.
  • Before & After: Include screenshots or comparisons (if applicable).
Event Before After
UP Before After
DOWN Before After
Certificate-expiry Before After
Testing Before After

Copilot AI review requested due to automatic review settings February 28, 2026 17:27
Copy link
Copy Markdown
Contributor

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

Adjusts push monitor startup behavior so overdue/down detection isn’t delayed by a full interval after a server restart, addressing long-interval push monitors staying incorrectly UP.

Changes:

  • Preloads the most recent heartbeat for push monitors on start() to decide whether to run an immediate check.
  • For push monitors with an existing heartbeat, runs safeBeat() immediately; for monitors with no prior heartbeat, keeps the initial grace delay.

Comment on lines +422 to +424
previousBeat = await R.findOne("heartbeat", " monitor_id = ? ORDER BY time DESC", [this.id]);
if (previousBeat) {
retries = previousBeat.retries;
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

The initial R.findOne("heartbeat", ...) for push monitors runs outside of safeBeat()/beat() error handling. If the DB query fails (e.g., transient DB lock or connection issue), start() will reject and the monitor may fail to start/resume. Consider wrapping this lookup in a try/catch (fall back to previousBeat = null) or moving it into safeBeat() so failures are handled consistently and the monitor can retry instead of aborting startup.

Suggested change
previousBeat = await R.findOne("heartbeat", " monitor_id = ? ORDER BY time DESC", [this.id]);
if (previousBeat) {
retries = previousBeat.retries;
try {
previousBeat = await R.findOne("heartbeat", " monitor_id = ? ORDER BY time DESC", [this.id]);
if (previousBeat) {
retries = previousBeat.retries;
}
} catch (e) {
console.trace(e);
UptimeKumaServer.errorLog(e, false);
log.error("monitor", "Failed to load previous heartbeat for push monitor, starting without previous state");
previousBeat = null;

Copilot uses AI. Check for mistakes.
Comment on lines 1149 to +1154
if (this.type === "push") {
setTimeout(() => {
if (previousBeat) {
safeBeat();
}, this.interval * 1000);
} else {
this.heartbeatInterval = setTimeout(safeBeat, this.interval * 1000);
}
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

This change alters push-monitor startup scheduling (immediate timeout evaluation when a prior heartbeat exists). There are backend monitor tests in test/backend-test/monitors/, but no regression test appears to cover push monitor restart behavior. Adding a unit/integration test that seeds a prior heartbeat and asserts start() triggers an immediate check (and does not wait a full interval) would help prevent regressions for long-interval push monitors.

Copilot generated this review using guidance from repository custom instructions.
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.

Push monitors with long intervals (>24h) fail to detect DOWN status

2 participants