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

feat: add proxy support for native fetch using undici #2537

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

cesaryuan
Copy link
Contributor

Description

Currently, Session.setProxy is not working for native fetch, which is used by readability.
So we need to set proxy for native fetch manually, refer to https://stackoverflow.com/a/76503362/14676508

PR Type

  • Feature
  • Bugfix
  • Hotfix
  • Other (please describe):

Linked Issues

Close #2375

Additional context

Changelog

  • I have updated the changelog/next.md with my changes.

@follow-reviewer-bot
Copy link

Thank you for your contribution. We will review it promptly.

Copy link

vercel bot commented Jan 10, 2025

@cesaryuan is attempting to deploy a commit to the RSS3 Team on Vercel.

A member of the Team first needs to authorize it.

@follow-reviewer-bot
Copy link

Suggested PR Title:

feat(proxy): add undici support for proxy configuration

Change Summary:
Added support for proxy configuration using undici for native fetch requests, enhancing the application's ability to manage network requests through proxies.

Code Review:

  • apps/main/src/lib/proxy.ts, lines 77-81: The current solution to handle native fetch via the undici ProxyAgent might be functional, but it lacks proper error handling mechanisms. It is important to ensure that the proxyUri is validated and that any potential exceptions from creating the ProxyAgent and setting the global dispatcher are caught and logged appropriately to avoid silent failures.

Here is a suggested change:

  try {
    const dispatcher = new ProxyAgent({ uri: new URL(proxyUri).toString() });
    setGlobalDispatcher(dispatcher);
    logger.info("Global dispatcher set with ProxyAgent successfully.");
  } catch (error) {
    logger.error("Failed to set global dispatcher with ProxyAgent:", error);
  }

This adds error logging and ensures that any issues in setting up the proxy for native fetch are reported.

To summarize:

  • Add try-catch block to handle potential exceptions when creating ProxyAgent and setting the global dispatcher.
  • Log errors appropriately.

@Innei Innei requested a review from lawvs January 11, 2025 04:20
@lawvs lawvs merged commit 6abb442 into RSSNext:dev Jan 13, 2025
3 of 6 checks passed
@follow-reviewer-bot
Copy link

Thank you @cesaryuan for your contribution! 🎉

Your pull request has been merged and we really appreciate your help in making this project better. We hope to see more contributions from you in the future! 💪

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.

Always "Fetching original content and processing..." in Readability for specific feeds
2 participants