Skip to content

[superlog] Skip ERROR logging for client-disconnect AbortErrors in RPC interceptor#478

Open
superlog-app[bot] wants to merge 1 commit into
stagingfrom
superlog/skip-abort-error-rpc-logging
Open

[superlog] Skip ERROR logging for client-disconnect AbortErrors in RPC interceptor#478
superlog-app[bot] wants to merge 1 commit into
stagingfrom
superlog/skip-abort-error-rpc-logging

Conversation

@superlog-app

@superlog-app superlog-app Bot commented Jun 14, 2026

Copy link
Copy Markdown

Summary

The API RPC interceptor logs AbortError ("The connection was closed.", code 20) at ERROR level whenever a browser closes a connection mid-request — navigation, tab close, page refresh. Every sample log shows status: 200, confirming the server already sent a successful response before the client disconnected. This produces false-positive ERROR incidents across all API endpoints.

The root cause is that logOrpcHandlerError in apps/api/src/rpc/interceptors.ts unconditionally calls logger.error(...) for every error without distinguishing client aborts from real server failures.

This patch adds a single guard: if the error is an AbortError (error.name === "AbortError"), return early rather than logging at ERROR. Real server errors continue to be logged as before.

An alternative approach would be to log AbortErrors at DEBUG or INFO level instead of silently dropping them. The current patch drops them entirely since these events carry no actionable server-side signal; logging at DEBUG is a reasonable alternative if visibility into abort frequency is desired.

Incident on Superlog


Was this PR helpful? Leave feedback — goes straight to the Superlog team.


Summary by cubic

Skip ERROR logging for client-disconnect AbortError in the API RPC interceptor to eliminate false error incidents when users navigate away or close tabs. All other errors continue to be logged at ERROR as before.

Written for commit 8ffc97f. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Jun 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
databuddy-status Ready Ready Preview, Comment Jun 14, 2026 11:57am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
dashboard Skipped Skipped Jun 14, 2026 11:57am
documentation Skipped Skipped Jun 14, 2026 11:57am

@unkey-deploy

unkey-deploy Bot commented Jun 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Unkey Deploy

Name Status Preview Inspect Updated (UTC)
api (preview) Ready Visit Preview Inspect Jun 14, 2026 11:58am

@greptile-apps

greptile-apps Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a single early-return guard in logOrpcHandlerError that silences ERROR-level logging for AbortErrors triggered by client-side disconnects (navigation, tab close, refresh), eliminating the false-positive error incidents documented in the linked Superlog incident.

  • The check (error instanceof Error && error.name === "AbortError") is idiomatic and correct — DOMException extends Error in modern runtimes, so both the Web API and Node/Bun flavors of AbortError are caught.
  • handlers.ts contains a parallel useLogger().error() catch block (wrapping createContext + handle) that does not yet carry the same guard; this path is unlikely to see AbortErrors in the normal RPC flow, but the inconsistency is worth noting.

Confidence Score: 4/5

Safe to merge — the change is a minimal, targeted suppression of well-understood false-positive noise with no effect on how real server errors are handled.

The guard is correct and the affected code path is narrow. The only open question is whether the equivalent unguarded catch block in handlers.ts could fire for AbortErrors during context creation, but that path is unlikely to be hit in practice.

The outer try-catch in apps/api/src/rpc/handlers.ts (lines 58–67) is the only spot that might warrant a follow-up guard.

Important Files Changed

Filename Overview
apps/api/src/rpc/interceptors.ts Adds an early-return guard for AbortError before the ERROR-level log call, correctly suppressing false-positive error noise from client-initiated disconnects.

Sequence Diagram

sequenceDiagram
    participant C as Client (Browser)
    participant E as Elysia (API)
    participant R as RPCHandler
    participant I as onError Interceptor
    participant L as logOrpcHandlerError

    C->>E: HTTP Request
    E->>R: handle(request, context)
    R->>R: Execute RPC procedure
    C-->>R: Connection closed (AbortError)
    R->>I: onError interceptor fires
    I->>L: logOrpcHandlerError(AbortError)
    Note over L: NEW: error.name === "AbortError"<br/>→ return early (no ERROR log)
    L-->>I: return (silent)
    R-->>E: RPCHandler returns response/error response
    E-->>C: Response (if connection still open)
Loading

Reviews (1): Last reviewed commit: "[superlog] Skip ERROR logging for client..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants