Skip to content

Conversation

leigaol
Copy link
Contributor

@leigaol leigaol commented Jun 3, 2025

Problem

The LSP start failure because

  1. node binary is blocked because of firewall
  2. chat UI js file is blocked because of firewall or anti virus
  3. lsp js file is broken post download because of security mechanism

Solution

  1. Bundle the JS LSP with the amazonq package.
  2. Re-start LSP wth the bundled JS files if and only if downloaded LSP does not work!
  3. Use the VS Code vended node to start the bundled LSP.

This was tested by

  1. Generated the vsix, which is now 20MB.
  2. Disconnect from internet, remove local LSP caches
  3. Install the new vsix
  4. Webview of chat should load.

also tested by manually corrupting the aws-lsp-codewhisperer.js

Limitations:

  1. The indexing library function will not work because it is missing.
  2. rg is not in the bundle

Ref: aws/aws-toolkit-jetbrains#5772


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@leigaol leigaol requested a review from a team as a code owner June 3, 2025 22:06
@leigaol leigaol marked this pull request as draft June 3, 2025 22:06
Copy link

github-actions bot commented Jun 3, 2025

  • This pull request modifies code in src/* but no tests were added/updated.
    • Confirm whether tests should be added or ensure the PR description explains why tests are not required.
  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

@leigaol leigaol requested review from andrewyuq and rli June 3, 2025 22:48
@leigaol leigaol marked this pull request as ready for review June 5, 2025 19:44
Comment on lines +20 to +24
try {
await lspSetupStage('all', async () => {
await lspSetupStage('launch', async () => await startLanguageServer(ctx, getBundledResourcePaths(ctx)))
})
} catch (error) {
Copy link
Contributor

@justinmk3 justinmk3 Jun 6, 2025

Choose a reason for hiding this comment

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

the fallback logic should live in the resolver, just like all the other fallback cases. it doesn't make sense to add a fallback at this level.

this fallback is no different than the other fallback cases in the resolver. it's just yet another fallback scenario.

Copy link
Contributor Author

@leigaol leigaol Jun 6, 2025

Choose a reason for hiding this comment

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

No. In the case of a firewall/anti virus, the resolver believes it successfully finished downloading and it then proceed to start the language server with the download path, but at that moment anti virus kicked in and broke it.

This outmost try catch can handle such cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

the resolver believes it successfully finished downloading and it then proceed to start the language server with the download path

isn't that a bug in the resolver that should be fixed / redesigned ?

Comment on lines +49 to +51
let resourcesRoots = [lspDir, dist]
if (this.mynahUIPath?.startsWith(globals.context.extensionUri.fsPath)) {
getLogger('amazonqLsp').info(`Using bundled webview resources ${bundledResources.fsPath}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this decision being made here instead of in LanguageServerResolver

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same reason as I mentioned above. When it failed to launch, there are cases when the anti virus modified/removed the downloaded artifacts later on. The LanguageServerResolver does not throw, it indeed successfully unzipped those artifacts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If LanguageServerResolver does not throw, I will not be able to resolve to bundled artifact

Copy link
Contributor

Choose a reason for hiding this comment

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

When it failed to launch, there are cases when the anti virus modified/removed the downloaded artifacts later on. The LanguageServerResolver does not throw, it indeed successfully unzipped those artifacts.

Can it do a step that verifies the contents after unzipping? I.e. whatever causes the AV to quarantine the artifacts, the resolver should do itself before continuing.

@leigaol leigaol merged commit 62d50d9 into aws:master Jun 6, 2025
30 of 31 checks passed
await ensureDirectoryExists(resourcesDir)

return new Promise((resolve, reject) => {
const manifestUrl = 'https://aws-toolkit-language-servers.amazonaws.com/qAgenticChatServer/0/manifest.json'
Copy link
Contributor

Choose a reason for hiding this comment

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

@leigaol Future note: this could be a source of confusion for cases like 756c286 when an alpha manifest is used. Unless this location is also updated.

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.

4 participants