File tree Expand file tree Collapse file tree 3 files changed +11
-11
lines changed
Expand file tree Collapse file tree 3 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { CodeWhispererStreamingServiceException } from '@amzn/codewhisperer-stre
1616import { driveLetterRegex } from './utilities/pathUtils'
1717import { getLogger } from './logger/logger'
1818import { crashMonitoringDirName } from './constants'
19+ import { RequestCancelledError } from './request'
1920
2021let _username = 'unknown-user'
2122let _isAutomation = false
@@ -618,7 +619,11 @@ function hasTime(error: Error): error is typeof error & { time: Date } {
618619}
619620
620621export function isUserCancelledError ( error : unknown ) : boolean {
621- return CancellationError . isUserCancelled ( error ) || ( error instanceof ToolkitError && error . cancelled )
622+ return (
623+ CancellationError . isUserCancelled ( error ) ||
624+ ( error instanceof ToolkitError && error . cancelled ) ||
625+ error instanceof RequestCancelledError
626+ )
622627}
623628
624629/**
Original file line number Diff line number Diff line change @@ -15,8 +15,7 @@ import { createHash } from '../crypto'
1515import { lspSetupStage , StageResolver , tryStageResolvers } from './utils/setupStage'
1616import { HttpResourceFetcher } from '../resourcefetcher/httpResourceFetcher'
1717import { showMessageWithCancel } from '../../shared/utilities/messages'
18- import { CancellationError , Timeout } from '../utilities/timeoutUtils'
19- import { RequestCancelledError } from '../request'
18+ import { Timeout } from '../utilities/timeoutUtils'
2019
2120// max timeout for downloading remote LSP assets progress, the lowest possible is 3000, bounded by httpResourceFetcher's waitUntil
2221const remoteDownloadTimeout = 5000
@@ -114,11 +113,6 @@ export class LanguageServerResolver {
114113 } else {
115114 throw new ToolkitError ( 'Failed to download server from remote' , { code : 'RemoteDownloadFailed' } )
116115 }
117- } catch ( err ) {
118- if ( err instanceof RequestCancelledError ) {
119- throw new CancellationError ( 'user' )
120- }
121- throw err
122116 } finally {
123117 timeout . dispose ( )
124118 }
Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ import { VSCODE_EXTENSION_ID } from '../extensions'
77import { getLogger , Logger } from '../logger/logger'
88import { ResourceFetcher } from './resourcefetcher'
99import { Timeout , CancelEvent , waitUntil } from '../utilities/timeoutUtils'
10- import request , { RequestCancelledError , RequestError } from '../request'
10+ import request , { RequestError } from '../request'
11+ import { isUserCancelledError } from '../errors'
1112
1213type RequestHeaders = { eTag ?: string ; gZip ?: boolean }
1314
@@ -120,8 +121,8 @@ export class HttpResourceFetcher implements ResourceFetcher<Response> {
120121 interval : 100 ,
121122 backoff : 2 ,
122123 retryOnFail : ( error : Error ) => {
123- // retry unless we got an user cancellation error
124- return ! ( error instanceof RequestCancelledError )
124+ // Retry unless the user intentionally canceled the operation.
125+ return ! isUserCancelledError ( error )
125126 } ,
126127 }
127128 )
You can’t perform that action at this time.
0 commit comments