diff --git a/packages/core/src/awsService/cloudWatchLogs/commands/tailLogGroup.ts b/packages/core/src/awsService/cloudWatchLogs/commands/tailLogGroup.ts index fdcb6ba0031..74ac67fca33 100644 --- a/packages/core/src/awsService/cloudWatchLogs/commands/tailLogGroup.ts +++ b/packages/core/src/awsService/cloudWatchLogs/commands/tailLogGroup.ts @@ -14,6 +14,7 @@ import { StartLiveTailResponseStream, } from '@aws-sdk/client-cloudwatch-logs' import { getLogger, ToolkitError } from '../../../shared' +import { uriToKey } from '../cloudWatchLogsUtils' export async function tailLogGroup( registry: LiveTailSessionRegistry, @@ -32,11 +33,11 @@ export async function tailLogGroup( region: wizardResponse.regionLogGroupSubmenuResponse.region, } const session = new LiveTailSession(liveTailSessionConfig) - if (registry.has(session.uri.toString())) { + if (registry.has(uriToKey(session.uri))) { await prepareDocument(session) return } - registry.set(session.uri.toString(), session) + registry.set(uriToKey(session.uri), session) const document = await prepareDocument(session) @@ -49,12 +50,12 @@ export async function tailLogGroup( } export function closeSession(sessionUri: vscode.Uri, registry: LiveTailSessionRegistry) { - const session = registry.get(sessionUri.toString()) + const session = registry.get(uriToKey(sessionUri)) if (session === undefined) { throw new ToolkitError(`No LiveTail session found for URI: ${sessionUri.toString()}`) } session.stopLiveTailSession() - registry.delete(sessionUri.toString()) + registry.delete(uriToKey(sessionUri)) } export async function clearDocument(textDocument: vscode.TextDocument) { @@ -102,7 +103,7 @@ async function handleSessionStream( //AbortSignal interrupts the LiveTail stream, causing error to be thrown here. //Can assume that stopLiveTailSession() has already been called - AbortSignal is only //exposed through that method. - getLogger().info(`Session stopped: ${session.uri.toString()}`) + getLogger().info(`Session stopped: ${uriToKey(session.uri)}`) } else { //Unexpected exception. session.stopLiveTailSession() diff --git a/packages/core/src/test/awsService/cloudWatchLogs/commands/tailLogGroup.test.ts b/packages/core/src/test/awsService/cloudWatchLogs/commands/tailLogGroup.test.ts index de73c806954..e364c70ce34 100644 --- a/packages/core/src/test/awsService/cloudWatchLogs/commands/tailLogGroup.test.ts +++ b/packages/core/src/test/awsService/cloudWatchLogs/commands/tailLogGroup.test.ts @@ -18,7 +18,7 @@ import { TailLogGroupWizardResponse, } from '../../../../awsService/cloudWatchLogs/wizard/tailLogGroupWizard' import { getTestWindow } from '../../../shared/vscode/window' -import { CloudWatchLogsSettings } from '../../../../awsService/cloudWatchLogs/cloudWatchLogsUtils' +import { CloudWatchLogsSettings, uriToKey } from '../../../../awsService/cloudWatchLogs/cloudWatchLogsUtils' import { installFakeClock } from '../../../testUtil' describe('TailLogGroup', function () { @@ -130,7 +130,7 @@ describe('TailLogGroup', function () { logGroupName: testLogGroup, region: testRegion, }) - registry.set(session.uri.toString(), session) + registry.set(uriToKey(session.uri), session) closeSession(session.uri, registry) assert.strictEqual(0, registry.size)