Skip to content

refactor: centralize ErrAbortHandler recovery in gin middleware#134

Merged
hrntknr merged 1 commit intomainfrom
refactor/sse-panic-recovery-middleware
Apr 3, 2026
Merged

refactor: centralize ErrAbortHandler recovery in gin middleware#134
hrntknr merged 1 commit intomainfrom
refactor/sse-panic-recovery-middleware

Conversation

@hrntknr
Copy link
Copy Markdown
Member

@hrntknr hrntknr commented Apr 3, 2026

Summary

Move SSE ErrAbortHandler panic handling from a per-handler recover() in proxy.go and ErrorHandler/isHeadersSent in transparent.go to a centralized CustomRecoveryWithZap middleware in main.go.

The previous approach (#128) suppressed all ErrAbortHandler panics in the proxy handler, which could mask legitimate reverse proxy copy failures (e.g., truncated responses appearing as successful). By handling it at the gin recovery middleware level, ErrAbortHandler is treated the same way net/http intended — silently aborting the connection — without interfering with normal error propagation.

Type of Change

  • refactor: A code change that neither fixes a bug nor adds a feature

Related Issues

Follows up on #128

…f per-handler recover

Move SSE panic handling from a per-handler recover() in proxy.go and
ErrorHandler in transparent.go to a centralized CustomRecoveryWithZap
middleware. This provides consistent ErrAbortHandler handling across the
entire app without masking legitimate copy errors in the reverse proxy.

Relates to #128
@hrntknr hrntknr merged commit 287e3c0 into main Apr 3, 2026
7 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/mcp-proxy/main.go 0.00% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

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