Skip to content

[superlog] Silence AbortError in RPC interceptor error logger#493

Merged
izadoesdev merged 1 commit into
stagingfrom
superlog/silence-abort-error-rpc-interceptor
Jun 30, 2026
Merged

[superlog] Silence AbortError in RPC interceptor error logger#493
izadoesdev merged 1 commit into
stagingfrom
superlog/silence-abort-error-rpc-interceptor

Conversation

@superlog-app

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

Copy link
Copy Markdown

Summary

Client connection drops on RPC endpoints (user navigates away, closes a browser tab, or a mobile device goes to sleep mid-request) are logged as ERROR by the logOrpcHandlerError interceptor. The error carries name="AbortError" and code=20 (the standard DOM abort code), but the server had already processed the request successfully (HTTP 200, cache hit) before the network-level drop happened. This produces noisy false-positive incidents in Superlog with no user-facing failure behind them.

The logOrpcHandlerError function registered via onError(...) on both the RPC and OpenAPI handlers logs every error unconditionally at ERROR level. An AbortError that originates from the client side is indistinguishable from a real server error without an explicit name check.

The fix adds an early return for errors whose name is "AbortError" before the useLogger().error(...) call, silently dropping client abort noise while preserving full ERROR logging for all genuine server faults. An alternative approach would be to log at DEBUG instead of dropping, which would keep the signal in verbose log modes without polluting the ERROR incident feed — either is reasonable if the team wants visibility into abort rates.

Incident on Superlog


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


Summary by cubic

Silences client-side AbortError noise in the RPC and OpenAPI error interceptor by skipping ERROR logs when a connection closes mid-request. Adds an early return in logOrpcHandlerError to prevent false Superlog incidents while keeping logging for real server errors.

Written for commit 2a0c841. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Jun 24, 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 24, 2026 12:11pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
dashboard Skipped Skipped Jun 24, 2026 12:11pm
documentation Skipped Skipped Jun 24, 2026 12:11pm

@unkey-deploy

unkey-deploy Bot commented Jun 24, 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 24, 2026 12:12pm

@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds an early-return guard in logOrpcHandlerError to silently swallow AbortError exceptions before they reach useLogger().error(...), preventing client-side connection drops (tab close, navigation, mobile sleep) from generating false-positive ERROR incidents in Superlog.

  • The instanceof Error && error.name === "AbortError" check is the idiomatic way to detect aborts in Bun/Node.js and correctly covers errors thrown by AbortController without needing to check code=20.
  • The error is currently dropped completely with no logging at any level, so abort rates become invisible; a debug-level log would preserve the signal without polluting the ERROR feed.

Confidence Score: 4/5

The change is a one-liner guard that only silences a specific, well-named error class; all other errors continue to be logged as before.

The guard correctly identifies client-initiated connection drops and prevents them from polluting the ERROR incident feed. The only concern is that the abort is completely invisible after the guard — no debug or info log — which removes any ability to observe abort rates or correlate them with infrastructure events. All genuine server errors remain unaffected.

No files require special attention; apps/api/src/rpc/interceptors.ts is the only change and its scope is narrow.

Important Files Changed

Filename Overview
apps/api/src/rpc/interceptors.ts Adds an early return for AbortError in the RPC error interceptor to suppress noisy false-positive ERROR logs from client connection drops; correct and minimal, though the error is silently dropped with no debug-level visibility into abort rates.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Client
    participant Server as RPC Handler
    participant Interceptor as logOrpcHandlerError
    participant Logger as useLogger()

    Client->>Server: RPC Request
    Server->>Client: HTTP 200 (response in-flight)
    Client--xServer: Connection closed (tab closed / navigate away)
    Server->>Interceptor: onError(AbortError)
    
    Note over Interceptor: Before this PR - Every AbortError becomes ERROR log
    Note over Interceptor: After this PR - AbortError triggers early return
    
    alt "error.name === AbortError"
        Interceptor-->>Server: return (silenced)
    else genuine server error
        Interceptor->>Logger: useLogger().error(...)
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Client
    participant Server as RPC Handler
    participant Interceptor as logOrpcHandlerError
    participant Logger as useLogger()

    Client->>Server: RPC Request
    Server->>Client: HTTP 200 (response in-flight)
    Client--xServer: Connection closed (tab closed / navigate away)
    Server->>Interceptor: onError(AbortError)
    
    Note over Interceptor: Before this PR - Every AbortError becomes ERROR log
    Note over Interceptor: After this PR - AbortError triggers early return
    
    alt "error.name === AbortError"
        Interceptor-->>Server: return (silenced)
    else genuine server error
        Interceptor->>Logger: useLogger().error(...)
    end
Loading

Reviews (1): Last reviewed commit: "[superlog] Silence AbortError in RPC int..." | Re-trigger Greptile

Comment on lines +8 to +10
if (error instanceof Error && error.name === "AbortError") {
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Silent drop vs. debug log: the AbortError is currently discarded with no trace, which means there's no way to observe abort rates in verbose/debug log modes or correlate them with performance regressions. Logging at debug level (instead of return) would keep the ERROR incident feed clean while still allowing the signal to surface when needed.

Suggested change
if (error instanceof Error && error.name === "AbortError") {
return;
}
if (error instanceof Error && error.name === "AbortError") {
useLogger().debug(error, { rpc: "interceptor", aborted: true });
return;
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@izadoesdev izadoesdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against staging. No code-level blockers found. This is a small targeted logging-noise fix: AbortError client disconnects are skipped before the RPC interceptor emits ERROR logs, while non-abort errors still flow through the existing error logger.

Note: this duplicates #478; I am treating #493 as the survivor because it is clean, green, and has clearer PR context. I will leave a tracking comment on #478 after this lands.

@izadoesdev izadoesdev merged commit 7f6ae6f into staging Jun 30, 2026
17 checks passed
@izadoesdev izadoesdev deleted the superlog/silence-abort-error-rpc-interceptor branch June 30, 2026 14:43
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.

1 participant