diff --git a/ts/src/connections/package.json b/ts/src/connections/package.json index 9a497504..9bceac12 100644 --- a/ts/src/connections/package.json +++ b/ts/src/connections/package.json @@ -18,8 +18,8 @@ "buffer": "^5.2.1", "debug": "^4.1.1", "vscode-jsonrpc": "^4.0.0", - "@microsoft/dev-tunnels-contracts": ">1.1.6", - "@microsoft/dev-tunnels-management": ">1.1.6", + "@microsoft/dev-tunnels-contracts": ">1.1.8", + "@microsoft/dev-tunnels-management": ">1.1.8", "@microsoft/dev-tunnels-ssh": "^3.11.36", "@microsoft/dev-tunnels-ssh-tcp": "^3.11.36", "uuid": "^3.3.3", diff --git a/ts/src/management/package.json b/ts/src/management/package.json index d65e4e8e..be19fdce 100644 --- a/ts/src/management/package.json +++ b/ts/src/management/package.json @@ -18,7 +18,7 @@ "buffer": "^5.2.1", "debug": "^4.1.1", "vscode-jsonrpc": "^4.0.0", - "@microsoft/dev-tunnels-contracts": ">1.1.6", + "@microsoft/dev-tunnels-contracts": ">1.1.8", "axios": "^1.6.2" } } diff --git a/ts/src/management/tunnelManagementHttpClient.ts b/ts/src/management/tunnelManagementHttpClient.ts index f0d999dc..c2672d15 100644 --- a/ts/src/management/tunnelManagementHttpClient.ts +++ b/ts/src/management/tunnelManagementHttpClient.ts @@ -780,12 +780,12 @@ export class TunnelManagementHttpClient implements TunnelManagementClient { if (error.code === 'ECONNABORTED') { // server timeout - errorMessage = 'Timeout waiting for server response.'; + errorMessage = `Timeout reached: ${error.message}`; } - if (error.message === 'Network Error' && signal.aborted) { + if (signal.aborted) { // connection timeout - errorMessage = 'Timeout connecting to server.' + errorMessage = `Signal aborted: ${error.message}` } if (error.response?.data) { @@ -1090,13 +1090,14 @@ export class TunnelManagementHttpClient implements TunnelManagementClient { let disposable: Disposable | undefined; const abortController = new AbortController(); + let timeout: NodeJS.Timeout | undefined = undefined; const newAbortSignal = () => { if (cancellation?.isCancellationRequested) { - abortController.abort(); + abortController.abort('Cancelled: CancellationToken cancel requested.'); } else if (cancellation) { - disposable = cancellation.onCancellationRequested(() => abortController.abort()); + disposable = cancellation.onCancellationRequested(() => abortController.abort('Cancelled: CancellationToken cancel requested.')); } else { - setTimeout(() => abortController.abort(), defaultRequestTimeoutMS); + timeout = setTimeout(() => abortController.abort('Cancelled: default request timeout reached.'), defaultRequestTimeoutMS); } return abortController.signal; } @@ -1136,6 +1137,9 @@ export class TunnelManagementHttpClient implements TunnelManagementClient { throw requestError; } finally { + if (timeout) { + clearTimeout(timeout); + } disposable?.dispose(); } } diff --git a/ts/test/tunnels-test/tunnelManagementTests.ts b/ts/test/tunnels-test/tunnelManagementTests.ts index 92eaeed8..986bc61f 100644 --- a/ts/test/tunnels-test/tunnelManagementTests.ts +++ b/ts/test/tunnels-test/tunnelManagementTests.ts @@ -138,7 +138,7 @@ export class TunnelManagementTests { error = e; } - assert(error?.message?.includes('Timeout waiting for server response.')); + assert(error?.message?.includes('Timeout reached: ')); } @test @@ -159,7 +159,7 @@ export class TunnelManagementTests { error = e; } - assert(error?.message?.includes('Timeout connecting to server.')); + assert(error?.message?.includes('Signal aborted: ')); } @test