Two causes behind a duplicate record#
| Cause A: the browser sent two requests | Cause B: one request was processed twice | |
|---|---|---|
| Network panel | Two POST rows with the same body, milliseconds or seconds apart | One POST row |
| Server or proxy logs | Two requests, two connections or two request IDs | One request ID at the edge, two executions further in, or a retry after a timeout |
| Typical reasons | A double click, a repeated Enter key, a button that stays enabled while the first request runs, a page that retries on timeout | A proxy or client library that retries a timed-out request, a queue that redelivers, a handler that is not idempotent |
| Where the fix goes | The form: disable or guard the submit while it is pending, and send an idempotency key | The server: make the operation idempotent and deduplicate retries |
Start with the count of POST requests in the Network panel for the action. That count covers only the tab you recorded: a second tab, another device or an earlier attempt you did not capture can still send a separate request. The deciding observation is the server's record of both writes: two request IDs mean two requests, wherever the second came from, and one request ID behind both writes means one request ran twice.
Reproduced in Chromium#
A local page had a Place order button whose click handler sent POST /orders with the cart in the body. A double click produced:
POST /orders 201
POST /orders 201
Both requests carried the same body, {"cart":"c_123"}. The button had no pending state, so the second click of the double click started a second request. That is Cause A, and the server, receiving two valid requests, created two orders.
Record the requests#
Repeating the action creates real records. Do it with a test account or in a staging environment, never on the affected customer's account. Where you cannot, read the requests already captured, such as a HAR file or the server's logs, instead of reproducing.
- Open the Network panel with Preserve log on, because the page may navigate after the order succeeds.
- Filter for the endpoint, such as
orders. - Repeat the action as the user did: a double click, Enter pressed twice, or a click during a slow response.
- For each
POST, note the time, status, body and any request ID in the response headers. - Ask whoever can read the server logs to match both duplicate records to their request IDs. Without that, report the count as what this tab sent, not as proof of a retry.
If you cannot reproduce it, ask what the user did with the page while it was loading. "I clicked again because nothing happened" points at Cause A with a slow response. A response time near a timeout, such as 30 seconds, followed by a second identical request, points at a retry in the page or a library.
Worked example: duplicate payments during a slow provider#
This example is fictional. On one afternoon, 14 customers were charged twice. The payment page shows a spinner after Pay and disables the button.
A support engineer reproduced with throttling on and clicked once. The Network panel showed one POST /payments that took 31 seconds and returned 201. The server's logs showed two executions with the same edge request ID, 30 seconds apart: the load balancer timed out the first upstream attempt at 30 seconds and retried it on another instance, while the first instance completed its charge.
The report said: the browser sends one payment request. The load balancer retries it after 30 seconds, and both attempts charge the card. The page's double-click guard works. That moved the fix to the server: an idempotency key per payment attempt, and no automatic retry of non-idempotent requests at the load balancer.
Idempotency keys#
An idempotency key is a unique value the client sends with a request that must not run twice. The server stores the key with the result and returns the stored result for a repeat. The IETF HTTP API working group's draft describes an Idempotency-Key header for this purpose, and several payment APIs use the same pattern. IETF draft: the Idempotency-Key header
For the report, it is enough to say whether the request carried such a key, and whether the two records share it.
What to put in the report#
- The number of
POSTrequests the browser sent, with times and bodies. - Response statuses and request IDs from the response headers.
- Whether the button or form showed a pending state.
- Any idempotency key header on the requests.
- The request ID behind each duplicate record from the server's logs, or, if you cannot read them, the time window to look at and the request IDs to match.
Questions#
Is disabling the button enough?
It prevents most Cause A duplicates from one page. It does not stop a second tab, a retry in the page's code, or Cause B. Server-side idempotency covers all of them.
Why are the duplicates seconds apart, not milliseconds?
A double click produces requests milliseconds apart. Seconds apart usually means a user who clicked again after waiting, or a retry after a timeout. The gap is evidence: put it in the report.
Can GET requests cause duplicates?
They should not change data. If a GET creates records, a browser prefetch or a link preview can trigger it without a click. Report the method alongside the duplicate.
Return to the method for browser bug reports for the other symptoms in this collection.