diff --git a/packages/core/src/shared/lsp/lspResolver.ts b/packages/core/src/shared/lsp/lspResolver.ts index 7a6fc4102b0..4959f675986 100644 --- a/packages/core/src/shared/lsp/lspResolver.ts +++ b/packages/core/src/shared/lsp/lspResolver.ts @@ -12,7 +12,7 @@ import AdmZip from 'adm-zip' import { TargetContent, logger, LspResult, LspVersion, Manifest } from './types' import { getApplicationSupportFolder } from '../vscode/env' import { createHash } from '../crypto' -import request from '../request' +import { HttpResourceFetcher } from '../resourcefetcher/httpResourceFetcher' export class LanguageServerResolver { constructor( @@ -165,9 +165,8 @@ export class LanguageServerResolver { } const downloadTasks = contents.map(async (content) => { - // TODO This should be using the retryable http library but it doesn't seem to support zips right now - const res = await request.fetch('GET', content.url).response - if (!res.ok || !res.body) { + const res = await new HttpResourceFetcher(content.url, { showUrl: true }).get() + if (!res || !res.ok || !res.body) { return false } diff --git a/packages/core/src/shared/lsp/manifestResolver.ts b/packages/core/src/shared/lsp/manifestResolver.ts index 36685890620..0cf27b1293b 100644 --- a/packages/core/src/shared/lsp/manifestResolver.ts +++ b/packages/core/src/shared/lsp/manifestResolver.ts @@ -5,10 +5,10 @@ import { getLogger } from '../logger/logger' import { ToolkitError } from '../errors' -import { RetryableResourceFetcher } from '../resourcefetcher/httpResourceFetcher' import { Timeout } from '../utilities/timeoutUtils' import globals from '../extensionGlobals' import { Manifest } from './types' +import { HttpResourceFetcher } from '../resourcefetcher/httpResourceFetcher' const logger = getLogger('lsp') @@ -40,14 +40,11 @@ export class ManifestResolver { } private async fetchRemoteManifest(): Promise { - const resourceFetcher = new RetryableResourceFetcher({ - resource: this.manifestURL, - params: { - timeout: new Timeout(manifestTimeoutMs), - }, - }) + const resp = await new HttpResourceFetcher(this.manifestURL, { + showUrl: true, + timeout: new Timeout(manifestTimeoutMs), + }).getNewETagContent(this.getEtag()) - const resp = await resourceFetcher.getNewETagContent(this.getEtag()) if (!resp.content) { throw new ToolkitError('New content was not downloaded; fallback to the locally stored manifest') } diff --git a/packages/core/src/shared/resourcefetcher/httpResourceFetcher.ts b/packages/core/src/shared/resourcefetcher/httpResourceFetcher.ts index 4a61ae47854..e85e1ded70b 100644 --- a/packages/core/src/shared/resourcefetcher/httpResourceFetcher.ts +++ b/packages/core/src/shared/resourcefetcher/httpResourceFetcher.ts @@ -134,51 +134,6 @@ export class HttpResourceFetcher implements ResourceFetcher { } } -export class RetryableResourceFetcher extends HttpResourceFetcher { - private readonly requestTimeoutMs: number - private readonly retryIntervalMs: number - private readonly resource: string - - constructor({ - resource, - params: { retryNumber = 5, retryIntervalMs = 3000, showUrl = true, timeout = new Timeout(5000) }, - }: { - resource: string - params: { - retryNumber?: number - retryIntervalMs?: number - showUrl?: boolean - timeout?: Timeout - } - }) { - super(resource, { - showUrl, - timeout, - }) - this.requestTimeoutMs = retryNumber * retryIntervalMs - this.retryIntervalMs = retryIntervalMs - this.resource = resource - } - - fetch(versionTag?: string) { - return waitUntil( - async () => { - try { - return await this.getNewETagContent(versionTag) - } catch (err) { - getLogger('lsp').error('Failed to fetch at endpoint: %s, err: %s', this.resource, err) - throw err - } - }, - { - timeout: this.requestTimeoutMs, - interval: this.retryIntervalMs, - retryOnFail: true, - } - ) - } -} - /** * Retrieves JSON property value from a remote resource * @param property property to retrieve diff --git a/packages/webpack.web.config.js b/packages/webpack.web.config.js index fc6ca86d1d9..0f82af67389 100644 --- a/packages/webpack.web.config.js +++ b/packages/webpack.web.config.js @@ -41,7 +41,7 @@ module.exports = (env, argv) => { * environments. The following allows compilation to pass in Web mode by never bundling the module in the final output for web mode. */ new webpack.IgnorePlugin({ - resourceRegExp: /httpResourceFetcher/, // matches the path in the require() statement + resourceRegExp: /node\/httpResourceFetcher/, // matches the path in the require() statement }), /** * HACK: the ps-list module breaks Web mode if imported, BUT we still dynamically import this module for non web mode