Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fazialnjd
Copy link

@fazialnjd fazialnjd commented Jul 12, 2025

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