Skip to content

refactor: use async context manager and improve error handling in reverse_proxy - #1183

Open
fazialnjd wants to merge 1 commit into
bihealth:mainfrom
fazialnjd:refactor/reverse-proxy-error-handling
Open

refactor: use async context manager and improve error handling in reverse_proxy#1183
fazialnjd wants to merge 1 commit into
bihealth:mainfrom
fazialnjd:refactor/reverse-proxy-error-handling

Conversation

@fazialnjd

@fazialnjd fazialnjd commented Jul 12, 2025

Copy link
Copy Markdown

Description

refactor: use async context manager and improve error handling in reverse_proxy

This PR refactors the reverse_proxy endpoint:

  • Uses async with httpx.AsyncClient() to manage connection lifecycle properly.
  • Adds try/except block to handle request-level errors gracefully.
  • Returns 502 on proxy errors, and 500 for unexpected internal failures.
  • Returns 404 for invalid proxy targets.

Motivation

Previously, some proxy requests caused intermittent 500 errors due to unclosed HTTP client sessions or unreachable services. This change improves error handling and stability.

Related Issues

No related issue was created for this change.

@fazialnjd fazialnjd changed the title Refactor reverse_proxy to use async context manager and improve error… refactor: use async context manager and improve error handling in reverse_proxy Jul 12, 2025
@fazialnjd
fazialnjd force-pushed the refactor/reverse-proxy-error-handling branch from 689cba7 to 781a08e Compare July 12, 2025 11:30
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