Skip to content

Event handling: error and retry notifications #7

Description

@athal7

Overview

Add notification handlers for error and retry events with configurable behavior.

Event Matrix

Event Condition Notification Priority
permission.updated Always Permission request high
session.status: idle After delay Idle notice default
session.status: retry First OR after N Retry notice high
session.error Debounced Error alert urgent

Retry Notification Logic

const retryNotifyFirst = process.env.NTFY_RETRY_NOTIFY_FIRST !== 'false'
const retryNotifyAfter = parseInt(process.env.NTFY_RETRY_NOTIFY_AFTER || '3', 10)

let retryCount = 0

// On retry event
retryCount++
const shouldNotify = (retryNotifyFirst && retryCount === 1) ||
                     (retryNotifyAfter > 0 && retryCount === retryNotifyAfter)

// On idle/busy event
retryCount = 0  // Reset counter

Error Notification Logic

const errorNotify = process.env.NTFY_ERROR_NOTIFY !== 'false'
const errorDebounce = parseInt(process.env.NTFY_ERROR_DEBOUNCE_MS || '60000', 10)

let lastError = null

// On error event
if (errorNotify) {
  const now = Date.now()
  if (!lastError || (now - lastError) > errorDebounce) {
    lastError = now
    // Send notification
  }
}

Tasks

  • Add retry event handling with counter
  • Add error event handling with debounce
  • Reset retry counter on idle/busy
  • Respect configuration for both features
  • Log when notifications are suppressed (debounced/filtered)

Questions

  • What is the exact event type for errors? Need to verify session.error or similar.
  • Does retry status include attempt count in properties?

Acceptance Criteria

  • First retry triggers notification (if enabled)
  • Nth retry triggers notification (if configured)
  • Errors are debounced within window
  • Counters reset appropriately

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions