Expiry Windows: Node.js Email Status, SMS Escalation, and Event Traces
TL;DR: For Node.js event notifications, send transactional email first, poll its delivery status, and use SMS fallback only while the password-reset token remains useful. The deciding constraint is the expiry clock: a late fallback can create noise without helping a locked-out customer. For a customer-support system, this is a reliability problem with a security boundary. The useful outcome is…
Node.js event notifications should prioritize transactional email over SMS fallback, relying on email delivery status to determine when to send a text message. This approach avoids creating unnecessary noise when a locked-out customer may not respond in time. The key consideration is the expiry window, which dictates when a delayed fallback becomes counterproductive.
The decision process is based on explicit states: email_pending, email_delivered, text_pending, and complete. The critical states are email_pending, email_delivered, text_pending, and complete, with the terminal expired state preventing the misuse of old password-reset requests. A reset notice object contains the notification ID, the reset request ID, an expiration timestamp, and separate email and SMS states.
The policy function determines the next channel to attempt based on the expiry time, email delivery status, and SMS delivery status. An observed email delivery does not automatically trigger a text message; the system must verify the inbox placement and human attention. A failed email indicates a stronger signal than a pending one.
For messages still pending, a deadline policy is necessary: polling occurs until there's enough time to act, after which the process stops. This policy ensures that a support agent can distinguish between an expired request and a delivery failure without exposing the reset secret. The notification record should indicate when the email was accepted or failed, when the fallback was claimed, and how much validity remained at each transition.
This approach prevents an unpleasant support pattern, where a customer follows a reset link and is told it expired because the worker kept retrying an unactionable transport state. The system should poll only pending records that are still eligible for escalation, store provider receipt IDs alongside channel states, normalize responses into a small set of states, and persist transitions atomically.
While webhooks can reduce latency, they should feed into the same state transition function, and polling remains necessary for the expiry check and idempotency.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.