Skip to content
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

fix(proxy): better error when upstream proxy fails #746

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

manniL
Copy link
Member

@manniL manniL commented May 5, 2024

πŸ”— Linked issue

#722

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR should ensure that proxyRequests fail gracefully instead of leading to an unhandled node error crashing the server.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Copy link

cloudflare-pages bot commented May 5, 2024

Deploying unjs-h3 with Β Cloudflare Pages Β Cloudflare Pages

Latest commit: 59dc90c
Status:Β βœ…Β  Deploy successful!
Preview URL: https://9e059241.unjs-h3.pages.dev
Branch Preview URL: https://fix-proxy-500.unjs-h3.pages.dev

View logs

@manniL manniL marked this pull request as ready for review May 5, 2024 13:57
@manniL manniL changed the title test: add failing proxy test fix: graceful fail for proxy May 5, 2024
});
} catch {
event.node.res.statusCode = 502;
event.node.res.statusMessage = "Bad Gateway";
Copy link
Member

Choose a reason for hiding this comment

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

I think only we can assume only proxy had been failed and perhaps we can double check if there is not already set statusCode and message on error (that currently is being ingored)

Additionally, this perhaps can be implemented directly in sendProxy util for consistent behavior

Copy link
Member Author

Choose a reason for hiding this comment

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

Moving back to draft until implemented! Good idea πŸ‘πŸ»

@pi0 pi0 changed the title fix: graceful fail for proxy fix(proxy): better error when upstream proxy fails May 7, 2024
@manniL manniL self-assigned this May 7, 2024
@manniL manniL marked this pull request as draft May 7, 2024 13:57
@manniL manniL marked this pull request as ready for review May 8, 2024 14:46
@manniL
Copy link
Member Author

manniL commented May 8, 2024

Updated to sendProxy.

I think only we can assume only proxy had been failed and perhaps we can double check if there is not already set statusCode and message on error (that currently is being ingored)

You mean an existing one in event.node.statusCode / statusMessage or in the error directly? If the latter, which values should I check?

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.

None yet

2 participants