Skip to content

Conversation

@tellorian
Copy link

@tellorian tellorian commented Jan 8, 2026

ℹ️ To keep reviews fast and effective, please make sure you’ve read our pull request guidelines

📝 Summary of changes done and why they are done

  • Reset retries counter to 0 when push heartbeat is received
  • Set monitor status to UP and update message
  • Ensure proper state management for push-type monitors

📋 Related issues

📄 Checklist

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.
  • 🔍 My code adheres to the style guidelines of this project.
  • ⚠️ My changes generate no new warnings.
  • 🛠️ I have reviewed and tested my code.
  • 📝 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).
  • 🔒 I have considered potential security impacts and mitigated risks.
  • 🧰 Dependency updates are listed and explained.

📷 Screenshots or Visual Changes

  • UI Modifications: Highlight any changes made to the user interface.
  • Before & After: Include screenshots or comparisons (if applicable).

Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=170527342

…h heartbeats

- Reset retries counter to 0 when push heartbeat is received
- Set monitor status to UP and update message
- Ensure proper state management for push-type monitors
@tellorian
Copy link
Author

@CommanderStorm Could you plz review my PR?

Copy link
Collaborator

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

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

I would expect this to be a fix in the following file instead

router.all("/api/push/:pushToken", async (request, response) => {

Since this is resonably convoluted code, could you try to add a testcase for this?

@CommanderStorm CommanderStorm added the pr:please address review comments this PR needs a bit more work to be mergable label Jan 8, 2026
@CommanderStorm CommanderStorm marked this pull request as draft January 8, 2026 20:10
…es in push API

- Revert incorrect fix from server/model/monitor.js
- Fix determineStatus function in server/routers/api-router.js to properly handle PENDING + maxretries exceeded case
- When previousHeartbeat.status === PENDING, status === DOWN, and retries >= maxretries,
  set status to DOWN and reset retries to 0 instead of incrementing retries
- Add comprehensive test suite to verify the fix and prevent regression
- This ensures push monitors properly reset retries when recovering from failure states
@tellorian tellorian marked this pull request as ready for review January 9, 2026 00:23
* @param isUpsideDown
* @param bean
*/
function determineStatus(status, previousHeartbeat, maxretries, isUpsideDown, bean) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you need to import functions to use them

@tellorian
Copy link
Author

@CommanderStorm I've reverted incorrect fix from server/model/monitor.js and applied correct fix to server/routers/api-router.js:
And also added a testcase for this.

- Simplify test structure following backend-test README guidelines
- Use descriptive test names with function() behavior format
- Remove redundant test cases and focus on core issue scenarios
- Use assert.strictEqual instead of assert.equal for consistency
- Remove unnecessary comments and duplicate flipStatus function
@tellorian tellorian force-pushed the fix/issue-6586-push-monitor-retries branch from f4811d9 to 645d313 Compare January 9, 2026 00:44
@tellorian
Copy link
Author

@CommanderStorm I've cleanned up test file following best practices

Copy link
Collaborator

@CommanderStorm CommanderStorm Jan 9, 2026

Choose a reason for hiding this comment

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

as said: please rename the test test/backend-test/test-push-api.js and import determineStatus. Currently, this is not really a test of what you did.

Also, please see the warnings in the files changed tab

CommanderStorm and others added 4 commits January 9, 2026 06:08
- Extract determineStatus function from api-router.js to separate module (server/determine-status.js)
- Rename test-push-api-comprehensive.js to test-determineStatus.js for clarity
- Update test to import determineStatus from dedicated module instead of defining duplicate
- Remove unused imports (flipStatus, MAINTENANCE) from test file
- Fix linting issues and ensure all tests pass

This change makes the determineStatus function properly testable and modular,
eliminating code duplication between the test and implementation.
@tellorian
Copy link
Author

@CommanderStorm I've made a new commit, could you please review it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

please explain why you did not just import from the backend

Copy link
Author

Choose a reason for hiding this comment

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

By creating server/determine-status.js:

✅ Clean import: const { determineStatus } = require("../../server/determine-status")
✅ No server overhead: Just the function and its minimal dependencies
✅ Proper unit test: Tests only the function logic
✅ Reusable: Function can now be imported anywhere without pulling in router code

Copy link
Collaborator

Choose a reason for hiding this comment

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

What I was asking for was a straightforward, technical explanation of the decision in the context of this codebase. The previous response listed benefits, but it didn’t clearly explain what concrete issue exists with importing from the backend here, or why this change is necessary rather than just stylistic.

Clean import

And that is not possible via the api-server?

No server overhead

What are you talking about?

Proper unit test: Tests only the function logic

And why do we need to move the function for this?

Reusable

Where would you like to use it and why?

@CommanderStorm CommanderStorm marked this pull request as draft January 10, 2026 01:26
@CommanderStorm CommanderStorm added the question Further information is requested label Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:please address review comments this PR needs a bit more work to be mergable question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Push monitor retries not reset after a heartbeat is received

2 participants