Trellis

Incident Investigation

Find out why a webhook fired twice.

Your logs say when it happened. Trellis brings the pull request, the code and the decision record into the same investigation, so your team can line them up against the timeline.

Incident WH-042 evt_042 delivered twice

Each moment in order, with what explains it.

  1. PR #42 merged09:02 · Change

    Pull request #42 makes the first retry wait 30 seconds instead of 5.

    The event ID stays the same on every attempt, which is what the delivery contract requires.

    • Pull request · #42
    • retry-policy.ts
    • webhook-delivery.md

    Illustrative change

    - firstRetryDelayMs: 5_000
    + firstRetryDelayMs: 30_000
      retryOn: ["timeout"]
      preserveEventId: true
  2. write_80109:13:02 · Receiver

    The receiver applies evt_042 and remembers its ID for 10 seconds.

    The write succeeds. The acknowledgment never reaches the sender.

    • handleEvent()
    • recentEvents

    Code

    await applyEvent(event);
    await recentEvents.put(event.id, {
      expiresInSeconds: 10,
    });
  3. Attempt 1 times out09:13:05 · Sender

    No acknowledgment, so the sender assumes nothing happened.

    A timeout can’t tell the sender whether the receiver already did the work. The contract expects repeats for exactly this reason.

    • webhook-delivery.md

    Decision record

    “Delivery is at least once. Retries retain the event ID. Receivers must make repeated delivery safe.”
  4. Attempt 2 sent09:13:35 · Sender

    Thirty seconds after the timeout, the same event goes out again.

    Before #42, this retry would have arrived inside the receiver’s 10-second window.

    • Pull request · #42
    • retry-policy.ts

    From your logs

    09:13:05 sender event=evt_042 attempt=1 timeout
    09:13:35 sender event=evt_042 attempt=2 sent
  5. Duplicate write09:13:35 · Receiver

    The duplicate check has already expired, so evt_042 is applied a second time.

    Two effect IDs for one event. The retry change is the trigger; the 10-second check is why it got through.

    • handleEvent()
    • Pull request · #42
    • webhook-delivery.md

    From your logs

    09:13:02 receiver event=evt_042 effect=write_801
    09:13:35 receiver event=evt_042 effect=write_802
  6. “We got it twice”09:14 · Report

    A customer reports the event twice. The team starts from a sequence, not a guess.

    Still open: how many other events were affected, and why the first acknowledgment was lost.

    • Incident · WH-042

A synthetic incident. Times and records come from your own tools; Trellis supplies the code, pull requests and documents you import.

The evidence

Why the second delivery got through

Seconds after the receiver’s first write, drawn to scale.
  • The change

    delivery/retry-policy.ts

    #42 moved the first retry from 5 to 30 seconds after a timeout.

  • The code

    receiver/handle-event.ts

    Checks recent IDs, applies the event, then caches the ID for 10 seconds.

  • The decision

    decisions/webhook-delivery.md

    At-least-once delivery. Receivers must handle repeats across the whole retry window.

When the decision record names both files, Trellis links it to each, so a person or an agent who opens one can find the decision and the other file. How Code Intelligence links code and the documents that name it

The response

Before you close it

A seated engineer and a standing colleague reviewing a printed event sequence together
AI-generated illustration.
  1. Count the real duplicates

    Match repeated event IDs against actual effects since the change merged. A redelivery is harmless; a second write isn’t.

  2. Agree on the mitigation with the owners

    Reverting #42 narrows the gap but doesn’t repair existing writes or make concurrent deliveries safe.

  3. Test the repeat, not just the first delivery

    Record the receipt with the effect, atomically where you can, and cover the full replay window.

A reproduction test to write
Given evt_042 has already produced one effect
When  its acknowledgment is lost
And   it is delivered again after 33 seconds
Then  the receiver acknowledges it without a second effect

Try it

Try it on an incident you’ve already solved.

Bring the repository and its docs. You’ll see which connections would have shortened the investigation, and which questions still need your own tools.