-
Notifications
You must be signed in to change notification settings - Fork 747
fix(amazonq): add a more descriptive issue for firewall problems #7251
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ export class LanguageServerResolver { | |
| private readonly manifest: Manifest, | ||
| private readonly lsName: string, | ||
| private readonly versionRange: semver.Range, | ||
| private readonly manifestUrl: string, | ||
| /** | ||
| * Custom message to show user when downloading, if undefined it will use the default. | ||
| */ | ||
|
|
@@ -90,7 +91,22 @@ export class LanguageServerResolver { | |
|
|
||
| /** Finds an older, cached version of the LSP server bundle. */ | ||
| private async getFallbackServer(latestVersion: LspVersion): Promise<LspResult> { | ||
| const fallbackDirectory = await this.getFallbackDir(latestVersion.serverVersion) | ||
| const cachedVersions = await this.getCachedVersions() | ||
| if (cachedVersions.length === 0) { | ||
| /** | ||
| * at this point the latest version doesn't exist locally, lsp download (with retries) failed, and there are no cached fallback versions. | ||
| * This _probably_ only happens when the user hit a firewall/proxy issue, since otherwise they would probably have at least | ||
| * one other language server locally | ||
| */ | ||
| throw new ToolkitError( | ||
| `Unable to download dependencies from ${this.manifestUrl}. Check your network connectivity or firewall configuration and then try again.`, | ||
| { | ||
| code: 'NetworkConnectivityError', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these error codes auto-populate the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah exactly, that's part of why I wanted to add the code here. It should give us a rough idea of how many people are effected |
||
| } | ||
| ) | ||
| } | ||
|
|
||
| const fallbackDirectory = await this.getFallbackDir(latestVersion.serverVersion, cachedVersions) | ||
| if (!fallbackDirectory) { | ||
| throw new ToolkitError('Unable to find a compatible version of the Language Server', { | ||
| code: 'IncompatibleVersion', | ||
|
|
@@ -142,13 +158,22 @@ export class LanguageServerResolver { | |
| assetDirectory: cacheDirectory, | ||
| } | ||
| } else { | ||
| await this.cleanupVersion(latestVersion.serverVersion) | ||
| throw new ToolkitError('Failed to download server from remote', { code: 'RemoteDownloadFailed' }) | ||
| } | ||
| } finally { | ||
| timeout.dispose() | ||
| } | ||
| } | ||
|
|
||
| private async cleanupVersion(version: string) { | ||
| // clean up the X.X.X download directory since the download failed | ||
| const downloadDirectory = this.getDownloadDirectory(version) | ||
| if (await fs.existsDir(downloadDirectory)) { | ||
| await fs.delete(downloadDirectory) | ||
| } | ||
| } | ||
|
|
||
| /** Gets the current local ("cached") LSP server bundle. */ | ||
| private async getLocalServer( | ||
| cacheDirectory: string, | ||
|
|
@@ -178,16 +203,9 @@ export class LanguageServerResolver { | |
| /** | ||
| * Returns the path to the most compatible cached LSP version that can serve as a fallback | ||
| **/ | ||
| private async getFallbackDir(version: string) { | ||
| private async getFallbackDir(version: string, cachedVersions: string[]) { | ||
| const compatibleLspVersions = this.compatibleManifestLspVersion() | ||
|
|
||
| // determine all folders containing lsp versions in the fallback parent folder | ||
| const cachedVersions = (await fs.readdir(this.defaultDownloadFolder())) | ||
| .filter(([_, filetype]) => filetype === FileType.Directory) | ||
| .map(([pathName, _]) => semver.parse(pathName)) | ||
| .filter((ver): ver is semver.SemVer => ver !== null) | ||
| .map((x) => x.version) | ||
|
|
||
| const expectedVersion = semver.parse(version) | ||
| if (!expectedVersion) { | ||
| return undefined | ||
|
|
@@ -203,6 +221,15 @@ export class LanguageServerResolver { | |
| return fallbackDir.length > 0 ? fallbackDir[0] : undefined | ||
| } | ||
|
|
||
| private async getCachedVersions() { | ||
| // determine all folders containing lsp versions in the parent folder | ||
| return (await fs.readdir(this.defaultDownloadFolder())) | ||
| .filter(([_, filetype]) => filetype === FileType.Directory) | ||
| .map(([pathName, _]) => semver.parse(pathName)) | ||
| .filter((ver): ver is semver.SemVer => ver !== null) | ||
| .map((x) => x.version) | ||
| } | ||
|
|
||
| /** | ||
| * Validate the local cache directory of the given lsp version (matches expected hash) | ||
| * If valid return cache directory, else return undefined | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,7 +69,6 @@ export class ManifestResolver { | |
|
|
||
| const localManifest = await this.getLocalManifest(true).catch(() => undefined) | ||
| if (localManifest) { | ||
| localManifest.location = 'remote' | ||
| return localManifest | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason I set My intuition was that |
||
| } else { | ||
| // Will emit a `languageServer_setup` result=failed metric... | ||
|
|
||
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 was broken in a different commit. Now the manifest download falls back to the local cache if an etag is found but it still reports the telemetry metric as "remote"
Technically this is a minor bug with reporting telemetry, since it should have been reported as a cache