DEV Community

GriffinHayes3461
GriffinHayes3461

Posted on

Node.js Domain Polling: Pending State Across Logistics Cutover and Rollback

Customer-owned DNS gives a logistics operator control over its dispatch hostname, but it also places a dependency outside the platform's deployment transaction. TL;DR: bound domain verification polling by attempts and elapsed time, persist a customer-visible pending state reason, and keep hostname cutover behind a separate approval condition. For a Node.js service, the essential example is the state contract: stopping a polling job must not silently turn an unverified domain into a verified one, or erase the explanation the customer needs to act.

Keep rollback separate.

Consider a proposed migration of dispatch.example.com between application deployments. The hostname is illustrative; so are the retry limits below. The question is who can publish the required DNS change and who can reverse it. A platform-owned zone gives the platform that authority. A customer-owned zone requires a handoff to the customer's DNS administrator, which makes a visible waiting state part of the migration design, rather than a cosmetic onboarding message.

What should the customer see when domain verification polling stops?

Only that its observation budget ended. A successful verification observation, a failed lookup, an exhausted retry budget, and permission to move production traffic are four different results; representing them with one boolean throws away precisely the information needed to explain a stalled logistics cutover. The proposed design therefore stores verification status independently from polling status and deployment status.

A useful customer response can say: verification pending; automatic checks paused; the expected DNS evidence has not been observed; the customer DNS administrator owns the next action. That response is actionable without claiming that the customer made an error. If a lookup times out, the explanation should instead say that the check could not complete. Absence of evidence and failure to obtain evidence deserve different reasons.

There is a standards boundary here. RFC 7489 specifies DMARC policy discovery through DNS TXT records, including the _dmarc name and the treatment of multiple remaining policy records. It does not define a general hostname ownership challenge, an application retry schedule, or a production routing readiness test. A DMARC policy record must not be presented as proof that the logistics platform may claim a hostname. If mail policy is part of the migration, evaluate that policy separately from the platform's ownership challenge.

The distinction matters. A perfectly legible waiting message can still describe the wrong test.

Store the observation with the migration generation

Treat verification evidence like a data-layer write: give it an identity, scope it to the migration that requested it, and reject an observation that belongs to an older generation. In this design, each migration stores its hostname, zone owner, expected-evidence identifier, generation, attempt count, deadline, last observation time, verification state, polling state, and reason. The expected-evidence identifier refers to a challenge defined by the application; it is not a DMARC field. Keep any sensitive challenge material out of the customer explanation.

For example, dispatch.example.com could have generation 7, customer ownership, three checks already consumed, verification pending, and polling active. If the operator replaces that challenge while the third check is running, the result from generation 7 must not verify generation 8. The worker should submit its observation with the generation it read, and the storage operation should apply it only if that generation still matches. This is a proposed consistency rule, not a claimed DNS guarantee.

Persist before acknowledging.

The other easily missed boundary is between lookup completion and state publication. A worker that reports success to its queue before recording the observation leaves a gap in which a subsequent worker or customer page can see stale state. Use the storage layer's conditional update or transaction facility to write the observation, consume the attempt, and establish the next scheduling decision together. If scheduling uses a separate queue, keep a durable scheduling intent alongside that update so a dispatcher can retry delivery without inventing another verification attempt.

The trade-off is extra storage coordination in exchange for an auditable customer explanation: which observation produced this customer-visible reason? A queue acknowledgment alone isn't enough. Log the migration identifier, generation, observation category, and state revision together. Avoid treating raw lookup output as the public explanation.

Bound retries without manufacturing a terminal verdict

Choose limits as deployment policy, then label them as such. The illustrative policy below permits four checks over a 15-minute window, with proposed intervals of 30, 90, and 180 seconds after unsuccessful observations. These numbers are an example budget, not a propagation guarantee or a standard recommendation. They limit automatic work; they do not promise when a customer's DNS change will become visible.

The reader looking for a Node.js example needs the same storage and scheduling contract as any other worker runtime. The following Python reference expresses only the decision function, so its behavior can be carried into that service without implying that a DNS client or queue has already been implemented. It accepts normalized observations from a separate verifier and returns a new persisted-state proposal.

from dataclasses import dataclass, replace
from enum import Enum


class Observation(Enum):
    MATCH = "match"
    NO_MATCH = "no_match"
    LOOKUP_ERROR = "lookup_error"


@dataclass(frozen=True)
class State:
    generation: int
    attempts: int
    deadline: float
    verification: str = "pending"
    polling: str = "active"
    reason: str = "Awaiting a verification check."
    next_check: float | None = None


MAX_ATTEMPTS = 4
DELAYS = (30, 90, 180)


def apply_observation(state, generation, observed_at, observation):
    if not isinstance(observation, Observation):
        raise ValueError("Unknown observation category")
    if generation != state.generation or state.polling != "active":
        return state
    if observed_at >= state.deadline or state.attempts >= MAX_ATTEMPTS:
        return replace(
            state, polling="paused", next_check=None,
            reason="Automatic checks paused; request another check.",
        )

    attempts = state.attempts + 1
    if observation is Observation.MATCH:
        return replace(
            state, attempts=attempts, verification="verified",
            polling="complete", next_check=None,
            reason="Expected verification evidence observed.",
        )

    reason = (
        "Expected DNS evidence was not observed."
        if observation is Observation.NO_MATCH
        else "The DNS lookup could not complete."
    )
    next_check = (
        observed_at + DELAYS[attempts - 1]
        if attempts < MAX_ATTEMPTS else None
    )
    if next_check is None or next_check >= state.deadline:
        return replace(
            state, attempts=attempts, polling="paused", next_check=None,
            reason=reason + " Automatic checks paused; request another check.",
        )
    return replace(
        state, attempts=attempts, reason=reason, next_check=next_check
    )
Enter fullscreen mode Exit fullscreen mode

Use UTC epoch seconds for both timestamps in this example. The worker adapter must enforce a lookup timeout within the remaining window, refuse to start after the deadline, and pass the completion time to the decision function. A scheduler also needs a deadline sweep that pauses an active row if no further observation arrives. Otherwise, a crashed worker can leave the customer reading “active” indefinitely even though the budget has expired.

This function is intentionally smaller than the worker. It neither performs DNS lookups nor provides concurrency control. Commit its result with a conditional write against the state revision that was read; a losing worker must reload rather than apply its old proposal to newer state. Duplicate queue deliveries should carry an observation identifier that storage can deduplicate. Without that check, two deliveries of the same result can consume two attempts.

Exhaustion preserves pending. A manual retry creates an explicitly authorized new budget and records who requested it; changing the challenge also advances the migration generation. Neither operation should grant permission to shift traffic.

Zone ownership determines the next action

The architectural comparison comes after the state contract because zone ownership changes who can act, while the need to retain evidence survives either choice. For this logistics migration, choose the control model by who must retain authority over the hostname and its rollback change. Pricing does not answer that question.

Decision Customer-owned zone Platform-owned zone
Publish the requested DNS change Customer DNS administrator acts through the handoff Platform operator acts within its zone authority
Explain a missing observation Show the expected change and customer action owner Show the platform action owner and latest observation
Plan reversal Agree on a customer contact and reversal procedure before cutover Assign an operator and retain the previous configuration
Operational trade-off Customer retains zone control; coordination crosses teams Platform controls the zone; its operations team owns that responsibility

This is an authority comparison, not a claim that either arrangement makes DNS observations instantaneous. It also assumes the stated zone owner actually has permission to edit the relevant records. Confirm that permission during preparation, especially where different teams own the logistics application and its public hostname.

A useful customer page shows the last completed check time, the current reason, whether another automatic check is scheduled, and the responsible party. Display “not checked yet” when there is no observation. Reserve an explanation such as “expected evidence not observed” for a completed check that actually returned that result.

Roll out the hostname change behind a separate gate

Before cutover, test the verifier's normalization and the worker's state transitions with a matching observation, an absent match, a lookup error, a stale generation, a duplicate delivery, and a result arriving at the deadline. Include storage failure after the lookup and queue failure after the state update. Those tests exercise the boundaries most likely to produce an incorrect customer explanation.

For the proposed dispatch migration, record the previous routing configuration and identify the person authorized to restore it, prepare the replacement application, and complete verification for the current generation. Then require a separate readiness decision for serving the hostname before shifting traffic. Ownership evidence alone says nothing about the replacement application's ability to serve dispatch requests correctly. Define the application health checks and reversal trigger with the logistics team before approving the change.

Retain the old deployment for the agreed rollback window. Observe application health alongside verification state, and rehearse the reversal procedure with the actual zone owner. Reversing a configuration change should not be described as proof that every client has already returned to the previous destination; keep the operational status open until the agreed observations support closure.

The completion criterion is explicit: the hostname serves the intended application, the customer can understand the verification state, and the authorized operator can execute the documented reversal. A poller reaching its limit satisfies none of those conditions by itself.

Sources

References:

  • RFC 7489, Domain-based Message Authentication, Reporting, and Conformance, especially Section 6.6.3 on DNS policy discovery. This source supports the DMARC boundary discussed above; the retry budget and migration state machine are proposed application design. https://datatracker.ietf.org/doc/html/rfc7489

Top comments (0)