From 48025caaca535b25eb1136968f47dea58b7c46ee Mon Sep 17 00:00:00 2001 From: paperclipbugbot Date: Fri, 20 Nov 2026 04:52:50 -0800 Subject: [PATCH] fix(ui): mark the connectivity probe's timeout abort as intentional (#22390) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The browser UI shows a connection banner. It checks the server with a health probe (`probeServerHealth` in `ui/src/lib/connectivity.ts`) > - The probe stops its own `fetch` after 10 seconds with a reasonless `controller.abort()`. The app catches that rejection > - A `fetch` wrapper outside the app, such as a browser extension, can drop the rejection. The browser then reports `AbortError: signal is aborted without reason` as an unhandled rejection, and Sentry records an error that has no user effect > - #22090 added a marked abort reason for the shared GET and a Sentry filter that drops only that marked object. The probe timeout did not use it > - This pull request makes the probe timeout abort with the same marked reason > - The benefit is that the probe's own timeout no longer shows as a production error, and every other `AbortError` is still reported ## Linked Issues or Issue Description No public issue exists. This is the problem, in the bug template fields: **What happened?** A hosted browser reported one unhandled rejection: `AbortError: signal is aborted without reason` (DOMException code 20, mechanism `onunhandledrejection`, native trusted promise). The stack is a `setTimeout` callback in `probeServerHealth` that calls `controller.abort()` on the `/api/health` probe. The tab was hidden and had just resumed. **Expected behavior** The probe's own timeout does not appear in error monitoring. A real abort failure still appears. **Steps to reproduce** 1. Replace `window.fetch` with a wrapper that calls the real `fetch` and attaches only `.then(() => {})` to its promise. 2. Make `/api/health` hang for more than 10 seconds. 3. The probe timeout aborts the request. The app's `try/catch` handles its own promise, but the wrapper's derived promise rejects with no handler. **Paperclip version or commit** Reported on release `651749bdb4`. `probeServerHealth` is unchanged on master up to this branch's base (`201abacd6e`). **Deployment mode** Hosted, browser UI (Chrome-family message text). Refs #22090 (same filter, shared GET call site) and #22380 (same approach, announcement card). I searched open PRs for `probeServerHealth` and `intentionalAbortReason` and found no duplicate for this call site. ## What Changed - `ui/src/lib/connectivity.ts`: the probe timeout calls `controller.abort(intentionalAbortReason())` instead of `controller.abort()`. - `ui/src/lib/connectivity.test.ts`: a new test uses a `fetch` that settles only when its signal aborts. It checks that the probe returns `{ reachable: false }` after 10 seconds and that the signal reason is the marked intentional reason. ## Verification - `cd ui && npx vitest run src/lib/connectivity.test.ts src/lib/sentry.test.ts src/api/client.test.ts` → 3 files, 80 tests pass. - Red check: without the `connectivity.ts` change, the new test fails (`isIntentionalAbortReason(signal.reason)` is `false`). - `cd ui && npx vitest related src/lib/connectivity.ts --run` → 346 of 347 files pass. The 2 failures in `src/components/Layout.viewport.test.tsx` also fail on unmodified `master` in this sandbox, so this change does not cause them. - `tsc --noEmit` for `ui` reports no errors in the changed files. - The existing real-SDK tests in `ui/src/lib/sentry.test.ts` (from #22090) prove that `beforeSend` drops a marked rejection and still sends an unmarked `AbortError`. ## Risks - Low risk. The filter matches by object identity, and only `intentionalAbortReason()` makes these objects. An `AbortError` from any other source is still reported. - The probe's abort message changes from the browser's text to "The operation was aborted.". The probe catches every rejection and does not read the message. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Opus 5.5 (Anthropic), model ID `claude-opus-5-5`, used through Claude Code with tool use (shell, file edits, test runs). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- ui/src/lib/connectivity.test.ts | 21 +++++++++++++++++++++ ui/src/lib/connectivity.ts | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ui/src/lib/connectivity.test.ts b/ui/src/lib/connectivity.test.ts index 8fd2ef18907..071cb70cf61 100644 --- a/ui/src/lib/connectivity.test.ts +++ b/ui/src/lib/connectivity.test.ts @@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { ApiError } from "@/api/client"; import { ApiUnavailableError } from "@/api/response"; import { createConnectivityStore, probeServerHealth, type ConnectivityStore, type ProbeResult } from "./connectivity"; +import { isIntentionalAbortReason } from "./intentional-abort"; const outage = new ApiError("Paperclip is restarting", 503, { error: "tenant_app_unavailable" }); const down: ProbeResult = { reachable: false, retryAfterMs: null }; @@ -281,4 +282,24 @@ describe("probeServerHealth", () => { ))); expect(await probeServerHealth()).toEqual({ reachable: false, retryAfterMs: 4_000 }); }); + + it("marks its own timeout abort as intentional", async () => { + vi.useFakeTimers(); + try { + let probeSignal: AbortSignal | undefined; + vi.stubGlobal("fetch", vi.fn((_input: RequestInfo | URL, init?: RequestInit) => { + probeSignal = init?.signal ?? undefined; + return new Promise((_resolve, reject) => { + probeSignal?.addEventListener("abort", () => reject(probeSignal?.reason), { once: true }); + }); + })); + const result = probeServerHealth(); + await vi.advanceTimersByTimeAsync(10_000); + expect(await result).toEqual({ reachable: false, retryAfterMs: null }); + expect(probeSignal?.aborted).toBe(true); + expect(isIntentionalAbortReason(probeSignal?.reason)).toBe(true); + } finally { + vi.useRealTimers(); + } + }); }); diff --git a/ui/src/lib/connectivity.ts b/ui/src/lib/connectivity.ts index 5551ea05fca..a88958c983c 100644 --- a/ui/src/lib/connectivity.ts +++ b/ui/src/lib/connectivity.ts @@ -25,6 +25,7 @@ import { createContext, createElement, useContext, useEffect, useSyncExternalStore, type ReactNode } from "react"; import { apiFetch } from "@/api/client"; import { isConnectivityError, isTransientError, parseRetryAfter } from "@/api/errors"; +import { intentionalAbortReason } from "./intentional-abort"; export type ConnectivityStatus = "online" | "reconnecting" | "offline"; @@ -304,7 +305,7 @@ export function createConnectivityStore(options: ConnectivityStoreOptions = {}): */ export async function probeServerHealth(): Promise { const controller = new AbortController(); - const timeout = setTimeout(() => controller.abort(), PROBE_TIMEOUT_MS); + const timeout = setTimeout(() => controller.abort(intentionalAbortReason()), PROBE_TIMEOUT_MS); try { const res = await apiFetch("/api/health", { credentials: "include",