{"record":{"id":"a0661396f9e41ff6","repo":"paperclipai/paperclip","slug":"the-pause-was-saved-but-stopping-could-not-be-ver","errorCode":null,"errorMessage":"The pause was saved, but stopping could not be verified. Refresh and try Stop again if work is still running.","messagePattern":"The pause was saved, but stopping could not be verified\\. Refresh and try Stop again if work is still running\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ui/src/lib/wait-for-stopped-runs.ts","lineNumber":31,"sourceCode":") {\n  const getRun = options.getRun ?? heartbeatsApi.get;\n  const deadline = Date.now() + (options.timeoutMs ?? 30_000);\n  let remaining = [...new Set(runIds)];\n  while (remaining.length > 0) {\n    let states;\n    let timeout: ReturnType<typeof setTimeout> | undefined;\n    try {\n      states = await Promise.race([\n        Promise.all(remaining.map((id) => getRun(id))),\n        new Promise<never>((_resolve, reject) => {\n          timeout = setTimeout(\n            () => reject(new Error(\"Stop verification timed out\")),\n            Math.max(0, deadline - Date.now()),\n          );\n        }),\n      ]);\n    } catch {\n      throw new Error(\n        \"The pause was saved, but stopping could not be verified. Refresh and try Stop again if work is still running.\",\n      );\n    } finally {\n      clearTimeout(timeout);\n    }\n    remaining = states\n      .filter((run) => {\n        if (LIVE_STATUSES.has(run.status)) return true;\n        if (!(\"runtimeMode\" in run) || run.runtimeMode !== \"native\" || run.status !== \"cancelled\")\n          return false;\n        const cancellation = run.resultJson?.nativeCancellation;\n        return (\n          !cancellation ||\n          typeof cancellation !== \"object\" ||\n          !(\"dispatchState\" in cancellation) ||\n          cancellation.dispatchState !== \"acknowledged\"\n        );\n      })","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/ui/src/lib/wait-for-stopped-runs.ts#L13-L49","documentation":"waitForStoppedRuns polls run states after a Stop/pause command until they confirm stopped, bounded by a deadline. If the confirmation race (poll or timeout promise) rejects — e.g. the stop-verification HTTP call fails or the deadline elapses — the original error is swallowed and replaced with this actionable message: the pause was persisted server-side, but the client could not verify the runs actually stopped.","triggerScenarios":"Calling waitForStoppedRuns (via executeTreeControl Stop) when the deadline expires before all runs report stopped, or the underlying state-polling request rejects (network error, 4xx/5xx).","commonSituations":"Runs take longer than the verification window to drain (long in-flight agent turns); network hiccup mid-poll; backend accepts the pause but an agent adapter ignores it so runs never report stopped; server slow under load.","solutions":["Refresh the issue/run list and retry Stop if work is still visibly running, as the message suggests.","Increase the verification deadline/budget if runs legitimately take long to stop.","Check the backend: confirm the pause persisted and investigate the adapter for runs that never transition to stopped.","Inspect the swallowed root cause (add logging in the catch) to distinguish timeout from poll failure."],"exampleFix":"// before\n} catch {\n  throw new Error(\"The pause was saved, but stopping could not be verified...\");\n}\n// after\n} catch (cause) {\n  console.warn(\"stop verification failed\", cause);\n  throw new Error(\"The pause was saved, but stopping could not be verified. Refresh and try Stop again if work is still running.\", { cause });\n}","handlingStrategy":"try-catch","validationCode":"const states = await fetchRunStates(issueId);\nconst allStopped = states.every(s => s === \"stopped\");\nif (!allStopped) await waitForStoppedRuns(issueId, { timeoutMs: 30_000 });","typeGuard":null,"tryCatchPattern":"try {\n  await waitForStoppedRuns(issueId);\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"stopping could not be verified\")) {\n    showNotice(\"Pause saved — verification pending. Refresh to confirm.\");\n  } else throw e;\n}","preventionTips":["Set the verification deadline from observed run-drain times, not a fixed guess.","Log the swallowed cause inside the catch so timeouts are distinguishable from poll failures.","Reconcile state on next load: refresh run states when the user returns to the page.","Alert on adapters whose runs frequently fail to reach the stopped state."],"tags":["timeout","polling","state-verification","network"],"backgroundTag":"request-timeout","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}