skip to content

A loan-application app is killed seconds after the user taps submit, before any response arrives. On relaunch, how should it decide whether to resume, resubmit or show the result?

level: seniorimportance: should knowfreq 47%

answer

  1. the outcome is unknown, not failed
  2. write the intent before the request
  3. an identifier the device already holds
  4. sending, submitted, failed
  5. ask first, never a fresh identifier

basics

~20 s

Before sending, persist a submission record holding a client-generated application identifier and a sending status. On relaunch, sending means the outcome is unknown: ask the server about that identifier, or resend reusing it, never with a new one.

solid answer

~40 s

The request died with the process, but it may or may not have reached the server, and that uncertainty is the whole problem. So before sending I persist a submission record next to the draft: a client-generated application identifier, the payload, and a status of `sending`. When the response arrives I set `submitted` and store the server's reference. On relaunch the record decides. `draft` means nothing was sent. `submitted` means show the confirmation. `sending` means the outcome is unknown, so the app asks the server for that identifier's status, or resends with the same identifier so the server can recognise a duplicate. It never mints a new identifier and never fires a second POST blind. Meanwhile the screen shows 'checking your application', not an active submit button.

code

pseudocode · 18 lines
pseudocode
on_app_launch(draft_id):
  record = load_submission_record(draft_id)
  if record is null or record.status == "draft":
    restore_form(draft_id)
  else if record.status == "submitted":
    show_confirmation(record.server_ref)
  else if record.status == "failed":
    show_review_with_error(record.reason)
  else if record.status == "sending":            # outcome unknown
    show("checking your application")
    result = ask_server_for_status(record.application_id)
    if result.found:
      mark_submitted(record, result.server_ref)
      show_confirmation(result.server_ref)
    else if result.not_found:
      resend(record)                            # same application_id, same payload
    else:                                       # offline or server error
      keep_status_and_check_later(record)

go deeper

for a junior

Remember that a request can reach the server even if the app never hears back, so 'no response' does not mean 'not sent'.

for a middle

Explain the submission record: a device-generated identifier, written to disk before sending, with sending, submitted and failed states driving the relaunch.

for a senior

Design the reconciliation: status lookup, resend with the same identifier, an honest 'checking' screen, and the edited-draft case as a new intent.

for a principal

Decide which user actions in the product deserve this treatment and which can be lost, and agree the identifier contract with the server team.

## Why process death makes the outcome unknown When the user taps **submit**, the app sends a request, typically a `POST` that creates the application on the server. If the process is killed before the response arrives, there are three possibilities, and the relaunched app cannot tell them apart from memory, because memory is gone: 1. The request never left the device. 2. The request reached the server and was **applied**, but the response was lost with the process. 3. The request reached the server and was **not** applied (rejected, or failed midway). A `POST` is not idempotent: sending it twice may create two loan applications. HTTP's own semantics say a client should not automatically retry a non-idempotent request unless it has some way to know the request is safe to repeat, or to detect that the original was never applied. The design's job is to give the relaunched app that knowledge. ## The submission record The fix is to write the user's **intent** to disk **before** the request leaves, and to update it as the outcome becomes known. | Status | Meaning | What the relaunched app does | |---|---|---| | `draft` | Never submitted | Restore the form at the saved step | | `sending` | Sent or about to be sent; outcome unknown | Show "checking your application", then reconcile | | `submitted` | Server confirmed, reference stored | Show the confirmation with the reference | | `failed` | Server gave a definite rejection | Show the reason and let the user fix and resubmit | The record holds a **client-generated application identifier**, created on the device when the user first submits (or when the draft is created) and saved with the record. It exists before the request does, so it survives exactly the event that loses the server's response. ## Order of operations 1. Generate the application identifier, if the draft does not have one yet. 2. Write the record with status `sending` and the payload it will send. 3. Send the request, carrying that identifier. 4. On a success response, write `submitted` and the server's reference. 5. On a definite rejection, write `failed` with the reason. 6. On a network error or timeout, leave `sending`: the outcome is still unknown. The ordering matters. If step 2 happened after step 3, a kill between them would leave no trace that anything was sent. ## Reconciling on relaunch - **Ask before acting.** A status lookup by the application identifier is a safe read; if the server knows it, mark `submitted` and show the confirmation. - **Resend only with the same identifier.** If the server does not know it, resending the same payload with the same identifier is safe, because a request that was still in flight can be recognised as a duplicate. How the identifier travels and how the server compares it belong to the request pipeline and the server. - **Keep the user informed.** The screen says "checking your application" rather than re-enabling the submit button, which would invite a second, distinct submission. - **Treat an edited draft as a new intent.** If the user changed the draft after the first attempt, that is a different request and needs their confirmation. A user who swiped the app away instead still gets this reconciliation, because the record is on disk: a deliberate dismissal asks for a fresh screen, not for the app to forget a submitted loan application. ## What this question owns and what it hands off This question owns deciding **what to persist** so a half-sent submission is resumed or resubmitted safely after relaunch. Neighbouring designs own the rest: the retry key's header and server-side storage belong to the request pipeline; a durable queue of many pending writes belongs to the offline outbox; uploading the ID photo in resumable chunks belongs to the media upload pipeline; transfers that the OS itself carries on after the app is gone belong to the background budget. ## Common mistakes - Assuming no response means the server never received the application. - Holding the submission status only in memory and "waiting for the response". - Generating a new identifier on each attempt, which defeats duplicate detection. - Silently re-sending on launch with no way for the server to recognise a duplicate.

  • Why generate the application identifier on the device instead of waiting for the server's?
    Because the server's identifier arrives in the response, which is exactly what process death can lose. A device-generated identifier exists before the request leaves, is saved with the record, and lets the relaunched app ask whether the server has application X or resend X so a duplicate can be recognised. How the server stores and compares it is the server's and the request pipeline's design.
  • Should the relaunched app resubmit automatically, or ask the user?
    Automatically only when a duplicate can be detected, because the same identifier is reused, and the draft has not changed since the attempt; HTTP's own rule is that a client should not blindly retry a non-idempotent request. Even then the screen says 'checking your application'. If the user edited the draft afterwards, it is a new intent and needs their confirmation.
  • Does a user swiping the app away change what happens to a submission in the sending state?
    No. The record lives on disk, and a deliberate dismissal does not erase disk. The user asked for a fresh screen, not for the app to forget an application they may already have submitted. The next launch reconciles the sending record and shows its real outcome.

  • The request died with the process, so resubmitting with a new identifier is safe.
  • Keep the submission status in memory; the response will update it.
  • No response means the server never received the application.
  • An ordinary in-app request finishes after the process dies and reports on relaunch.
  • Re-enable the submit button on relaunch and let the user tap again.