Skip to content

fix: prevent premature webhook auto-disable and allow re-enable#364

Merged
KMKoushik merged 4 commits intomainfrom
fix/webhook-auto-disable-reenable
Feb 27, 2026
Merged

fix: prevent premature webhook auto-disable and allow re-enable#364
KMKoushik merged 4 commits intomainfrom
fix/webhook-auto-disable-reenable

Conversation

@KMKoushik
Copy link
Member

@KMKoushik KMKoushik commented Feb 27, 2026

Summary

  • fix webhook failure handling to evaluate auto-disable using the persisted post-increment failure count, preventing stale-state one-failure deactivations after manual reset/reactivation
  • allow AUTO_DISABLED webhooks to be activated again from both webhook list and webhook detail actions in the dashboard
  • add webhook service unit coverage for headers, retry behavior, failure lifecycle, auto-disable threshold logic, re-enable reset behavior, and test webhook payload creation

Testing

  • pnpm --filter web exec vitest run -c vitest.unit.config.ts \"src/server/service/webhook-service.unit.test.ts\"

Summary by cubic

Fixes webhook failure handling to count failures per failed call and prevent early auto-disable. Restores the ability to re-enable AUTO_DISABLED webhooks in the dashboard.

  • Bug Fixes
    • Increment consecutiveFailures only after a call exhausts retries, and decide auto-disable using the persisted post-increment counter in a transaction to avoid one-failure deactivations after resets.
    • Enable “Re-enable” for AUTO_DISABLED webhooks on list and detail pages; activating clears consecutiveFailures and shows the correct button label.
    • Add unit tests for headers/retries/failure lifecycle/threshold/re-enable reset/test payload; mock limit service to avoid mailer deps in CI; docs add email.rendering_failure, use usesend-js, and clarify “30 consecutive failed calls”.

Written for commit 55c9d56. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Added email.rendering_failure event type for webhooks
  • Improvements

    • Clarified webhook action labels/states to show "Resume" or "Re-enable" and simplified button disabled behavior
    • Standardized wording to "30 consecutive failed calls" and unified "failed calls" phrasing across guidance
    • Improved transactional handling of webhook failures and auto-disable logic
  • Documentation

    • Updated webhook guide, event table formatting, and SDK examples (usesend → usesend-js)
  • Tests

    • Added comprehensive unit tests for webhook processing and auto-disable scenarios

Use persisted failure counters when deciding auto-disable status and restore dashboard re-enable flow so webhooks are not deactivated unexpectedly after reset.
@vercel
Copy link

vercel bot commented Feb 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
unsend-marketing Ready Ready Preview, Comment Feb 27, 2026 8:40pm

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3dbe71d and 55c9d56.

📒 Files selected for processing (3)
  • apps/docs/guides/webhooks.mdx
  • apps/web/src/server/service/webhook-service.ts
  • apps/web/src/server/service/webhook-service.unit.test.ts

Walkthrough

This PR updates webhook behavior and docs: adds an email.rendering_failure event in docs and replaces usesend imports with usesend-js; refactors UI action rendering to use a new canActivate boolean for PAUSED/AUTO_DISABLED states and adjusts button disabled logic; changes webhook-service failure handling to perform consecutive-failure increments and potential auto-disable inside a single transaction; and adds comprehensive unit tests covering retries, failure counting, auto-disable, re-enable, and test-call creation.

Possibly related PRs

Suggested labels

codex

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately summarizes the main changes: fixing premature webhook auto-disable logic and enabling re-enable functionality for auto-disabled webhooks, which aligns with the core objectives of the changeset.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 27, 2026

Deploying usesend with  Cloudflare Pages  Cloudflare Pages

Latest commit: 55c9d56
Status:⚡️  Build in progress...

View logs

Only increment consecutive failure counters after a call exhausts retries, while keeping the 30-call auto-disable threshold and stale-state protection.
Mock limit service in webhook unit tests so Vitest does not resolve team-service and mailer paths requiring usesend-js during CI.
@KMKoushik KMKoushik merged commit edcd32a into main Feb 27, 2026
3 of 4 checks passed
@KMKoushik KMKoushik deleted the fix/webhook-auto-disable-reenable branch February 27, 2026 20:40
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.

1 participant