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

Add proxy support via global-agent #442

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

muffl0n
Copy link

@muffl0n muffl0n commented May 30, 2024

Fixes #438

@muffl0n muffl0n mentioned this pull request May 30, 2024
src/cache.js Outdated
@@ -2,6 +2,9 @@ import got from "got";
import logger from "./logger.js";
import { parseSchema } from "./parser.js";

import { bootstrap } from "global-agent";
bootstrap();
Copy link
Owner

Choose a reason for hiding this comment

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

Can you explain the thought process behind initialising this in cache.js?

I'd have thought loading it right at the top of the app bootstrap process (index.js) would make the most sense.

Copy link
Author

Choose a reason for hiding this comment

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

It's the only place got (and therefore global-agent) is used. Wanted to keep them at the same place.

But as mentioned beforehand: my knowledge with node is limited. So feel free to move the code anywhere else.

Copy link
Owner

@chris48s chris48s Jun 3, 2024

Choose a reason for hiding this comment

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

If it works in index.js I think I'd be inclined to put it there. Although cache.js is the only places that got is invoked at the moment that might not always be true. If we can bootstrap this right at the "top" of the app, then its less likely I will break proxy functionality as the codebase evolves.

This is especially important given this is a feature that I am not going to be using myself. In fact, its a feature that is quite hard for me to test in any way. I don't have access to a proxy server (I guess I could install one locally). I looked over a bunch of projects on GitHub that use global-agent hoping to see how to write a test for this and I can't see any with an automated test for the proxy functionality.

Copy link
Author

Choose a reason for hiding this comment

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

Sounds reasonable! Thanks for your feedback!
I just moved the code to index.js in 75d0696

Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/global-agent@3.0.0 environment, network Transitive: eval +27 757 kB gajus

View full report↗︎

@chris48s chris48s merged commit 525dbf3 into chris48s:main Jun 3, 2024
7 checks passed
@muffl0n muffl0n deleted the add-proxy-support branch June 6, 2024 09:13
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.

Native proxy support
2 participants