-
-
Notifications
You must be signed in to change notification settings - Fork 243
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(request): proxy-agent breaks Studio #580
Conversation
src/request.ts
Outdated
const options = | ||
typeof process === 'object' && process.env.PROXY ? { ...opts, agent: new ProxyAgent(process.env.PROXY) } : opts; | ||
if (typeof process === 'object' && process.env.PROXY) { | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to import every time a request is made? Is that gonna be ok for performance/memory usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
Luckily, Node.js caches modules (can be checked under require.cache), therefore they are loaded and executed only once unless one clears the cache.
That said, we should be okay.
Note, even though import
is used here, it's replaced with a require
call when we compile the code from TS to JS.
I don't take bundlers into account, since we don't aim to run this code in a browser, but they are no different.
====stdout==== | ||
|
||
{document} | ||
2:9 error invalid-ref FetchError: request to http://localhost:3002/foo.json failed, reason: connect ECONNREFUSED 127.0.0.1:3001 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a tad dumb. We could spin up a server.
Should be fine for now.
Checklist
Does this PR introduce a breaking change?
Additional context
This is almost impossible to cover with tests, as Studio has quite a specific setup. We just gotta be careful and avoid running Node specific code as much as possible.