Skip to content

[Backend] notificationService cleanup interval lacks a try/catch around its async callback #15

Closed

Description

@grantfox-oss

Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0

Why this matters

In src/services/notificationService.ts the cleanup setInterval awaits deleteOldNotifications and deleteReadAndArchived with no surrounding try/catch (unlike defaultChecker and scoreReconciliation), so a failing query produces an unhandled promise rejection.

Acceptance criteria

  • Wrap the cleanup callback body in try/catch and log failures via winston
  • Ensure a single failed cleanup run does not stop future runs
  • Follow the void-IIFE pattern used by the other schedulers
  • Add a test that a thrown error in cleanup is caught and logged

Files to touch

  • src/services/notificationService.ts

Out of scope

  • Changing retention defaults
  • Cleanup metrics dashboard

Activity

  1. added
    bugSomething isn't working
    GrantFox OSSIssue tracked in GrantFox OSS
    Maybe RewardedIssue may be eligible for a GrantFox reward
    on Jun 17, 2026
  2. Amarjeet325 commented on Jun 19, 2026

    @Amarjeet325

    Hi, maintainers 👋.
    I’d like to work on this issue.
    I’m a full-stack developer and smart contract expert; I have previously contributed to multiple open-source projects.

    Could you please assign this issue to me?

  3. Delightech28 commented on Jun 20, 2026

    @Delightech28
    Contributor

    I'd like to work on this

  4. ogazboiz commented on Jun 21, 2026

    @ogazboiz
    Contributor

    Happy to take this. The root of it is that setInterval doesn't await its callback, so an async cleanup callback that throws has nowhere for its rejection to land, which is the unhandled rejection. I'd fix it the way defaultChecker and scoreReconciliation already do: wrap the body in a void-IIFE with a try/catch inside, awaiting deleteOldNotifications and deleteReadAndArchived in the try and logging any failure via winston in the catch. Because the catch sits inside the per-run IIFE, a single failed run is logged and swallowed while the interval keeps firing, so future runs aren't affected.

    I'd match the existing scheduler pattern rather than introduce a new one, and add a test that forces a throw in cleanup and asserts it's caught and logged. I'll stay in scope, so no retention-default or metrics changes. I'll also claim it in the Telegram group as the issue asks. Please assign this to me.

  5. Johnpii1 commented on Jun 21, 2026

    @Johnpii1
    Contributor

    Hello Sir,

    I came across your project and I’m really interested in contributing.

    I have experience with React for building responsive, user-friendly interfaces, and I’m also familiar with smart contracts and blockchain basics. I focus on writing clean, scalable code and improving user experience.

    I’m a fast learner and ready to get started immediately. Please let me know the next steps.

    Thank you.

    Best regards,
    Johnpaul

  6. grantfox-oss commented on Jun 21, 2026

    @grantfox-oss
    Author

    🦊 GrantFox — @Johnpii1 has been assigned to this issue as part of the Official Campaign campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #15)
    2. Your PR will be reviewed by the LabsCrypt maintainers

    Good luck! Track your progress on GrantFox.

  7. grantfox-oss commented on Jun 29, 2026

    @grantfox-oss
    Author

    🎉 This issue has been marked as completed on GrantFox as part of the Official Campaign campaign!

    @Johnpii1's PR #40 was approved and merged by @ogazboiz.

    🏆 @Johnpii1: You earned 35 FoxPoints for this contribution! Your current tier: Builder (1,031 total points). Track your full progress on GrantFox.

    👏 Great work, @Johnpii1! Keep contributing to LabsCrypt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions