diff --git a/server/aws-lsp-codewhisperer/src/client/streamingClient/codewhispererStreamingClient.ts b/server/aws-lsp-codewhisperer/src/client/streamingClient/codewhispererStreamingClient.ts index 2110651b7..3f555c32e 100644 --- a/server/aws-lsp-codewhisperer/src/client/streamingClient/codewhispererStreamingClient.ts +++ b/server/aws-lsp-codewhisperer/src/client/streamingClient/codewhispererStreamingClient.ts @@ -17,8 +17,14 @@ export async function createStreamingClient( const creds = credentialsProvider.getCredentials('bearer') let clientOptions - 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' + const proxyUrl = isNodeJS ? (process.env.HTTPS_PROXY ?? process.env.https_proxy) : undefined + const certs = isNodeJS + ? process.env.AWS_CA_BUNDLE + ? [readFileSync(process.env.AWS_CA_BUNDLE)] + : undefined + : undefined if (proxyUrl) { const agent = new HttpsProxyAgent({ diff --git a/server/aws-lsp-codewhisperer/src/language-server/proxy-server.ts b/server/aws-lsp-codewhisperer/src/language-server/proxy-server.ts index c11ec53d5..6d4ba4c3d 100644 --- a/server/aws-lsp-codewhisperer/src/language-server/proxy-server.ts +++ b/server/aws-lsp-codewhisperer/src/language-server/proxy-server.ts @@ -28,9 +28,14 @@ export const QNetTransformServerTokenProxy = QNetTransformServerToken((credentia export const QChatServerProxy = QChatServer(credentialsProvider => { let clientOptions: ChatSessionServiceConfig | undefined - - 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' + const proxyUrl = isNodeJS ? (process.env.HTTPS_PROXY ?? process.env.https_proxy) : undefined + const certs = isNodeJS + ? process.env.AWS_CA_BUNDLE + ? [readFileSync(process.env.AWS_CA_BUNDLE)] + : undefined + : undefined if (proxyUrl) { clientOptions = () => { diff --git a/server/aws-lsp-codewhisperer/src/language-server/utils.ts b/server/aws-lsp-codewhisperer/src/language-server/utils.ts index aa75ed427..03cbf9508 100644 --- a/server/aws-lsp-codewhisperer/src/language-server/utils.ts +++ b/server/aws-lsp-codewhisperer/src/language-server/utils.ts @@ -133,10 +133,16 @@ export function getEndPositionForAcceptedSuggestion(content: string, startPositi export const makeProxyConfig = async (workspace: Workspace) => { let additionalAwsConfig: ConfigurationOptions = {} - const proxyUrl = process.env.HTTPS_PROXY ?? process.env.https_proxy + // 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' + const proxyUrl = isNodeJS ? (process.env.HTTPS_PROXY ?? process.env.https_proxy) : undefined if (proxyUrl) { - const certs = process.env.AWS_CA_BUNDLE ? [await workspace.fs.readFile(process.env.AWS_CA_BUNDLE)] : undefined + const certs = isNodeJS + ? process.env.AWS_CA_BUNDLE + ? [await workspace.fs.readFile(process.env.AWS_CA_BUNDLE)] + : undefined + : undefined const agent = new HttpsProxyAgent({ proxy: proxyUrl, ca: certs,