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: make proxy nodejs specific logic available only for nodejs runtime #716

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

francescoopiccoli
Copy link
Contributor

@francescoopiccoli francescoopiccoli commented Jan 9, 2025

Problem

this is a short term fix, to fix the webworker bundling. We will implement a better solution very soon.
We want to avoid having nodejs specific logic (process.env.VARIABLE) in lsp-codewhisperer as it breaks the webworker bundling, for which process is not defined.

Solution

If/else check to see if we are in node.js env
I tested the changes by testing the proxy

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@francescoopiccoli francescoopiccoli requested a review from a team as a code owner January 9, 2025 14:28
@francescoopiccoli
Copy link
Contributor Author

francescoopiccoli commented Jan 9, 2025

There is an occurrence of process.env.HTTPS_PROXYalso in servers/aws-lsp-identity/srs/sso.utils.ts, I am not sure if I should implement the fix there to, as it does not affect the webworker bundling.

const proxyUrl = process.env.HTTPS_PROXY ?? process.env.https_proxy
const certs = process.env.AWS_CA_BUNDLE ? [readFileSync(process.env.AWS_CA_BUNDLE)] : undefined
// short term solution to fix webworker bundling, broken due to this node.js specific logic in here
const isNodeJS: boolean = typeof process !== 'undefined' && process.release && process.release.name === 'node'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we pass HTTPS_PROXY and AWS_CA_BUNDLE as a config value from the runtime - the same way as we started doing for other env vars? It would not be that complex, but more clean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As this is very short term, I opted for the easiest solution that did the job, imo a more clean solution makes sense if it stays in the codebase indefinitely. Passing down via runtime is another option, not that complex but more work than this for sure (see https://github.com/aws/language-servers/pull/711/files).
If you have a strong preference for the runtime option, I am good with implementing that solution here as well, let me know!

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.

3 participants