Skip to content

Conversation

@keeganirby
Copy link
Contributor

@keeganirby keeganirby commented Dec 17, 2024

Problem

Currently, the TailLogGroup tests are passing, but emitting noisy errors in the CI logs:

<...>
No LiveTail session found for URI: test-region:test-log-group:all: Error: No LiveTail session found for URI: test-region:test-log-group:all
    at D:\a\aws-toolkit-vscode\aws-toolkit-vscode\packages\core\src\awsService\cloudWatchLogs\commands\tailLogGroup.ts:94:19
    at AsyncLocalStorage.run (node:async_hooks:346:14)
<...>

The cause for this, is that the event listener for closing the tailing session when Editor tabs close in TailLogGroup is not being disposed of. Disposal happens here. However, currently the "mock response stream" in the test blocks indefinitely on an un-resolvable promise. So the test ends, and this finally block never triggers.

Solution

Instead of using an un-resolving promise to keep the mock responseStream open, use an AbortController. When the tests no longer need the functionality of the disposables, the test can fire the AbortController. This causes the stream to exit exceptionally, which triggers the finally block in TailLogGroup and runs disposal.

This stops the event listeners from running after the test is completed, and has eliminated the noisy logs. I have tested this by running npm run test from the CLI.


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.

License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@keeganirby keeganirby marked this pull request as ready for review December 17, 2024 20:45
@keeganirby keeganirby requested a review from a team as a code owner December 17, 2024 20:45
Copy link
Contributor

@justinmk3 justinmk3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that No LiveTail session found for URI noise is no longer in the logs. Nice!

@justinmk3 justinmk3 merged commit 4ddea68 into aws:master Dec 17, 2024
25 of 26 checks passed
karanA-aws pushed a commit to karanA-aws/aws-toolkit-vscode that referenced this pull request Jan 17, 2025
…s#6267

## Problem
Currently, the TailLogGroup tests are passing, but emitting noisy errors
in the CI logs:
```
<...>
No LiveTail session found for URI: test-region:test-log-group:all: Error: No LiveTail session found for URI: test-region:test-log-group:all
    at D:\a\aws-toolkit-vscode\aws-toolkit-vscode\packages\core\src\awsService\cloudWatchLogs\commands\tailLogGroup.ts:94:19
    at AsyncLocalStorage.run (node:async_hooks:346:14)
<...>
```

The cause for this, is that the event listener for closing the tailing
session when Editor tabs close in TailLogGroup is not being disposed of.
Disposal happens
[here](https://github.com/aws/aws-toolkit-vscode/blob/master/packages/core/src/awsService/cloudWatchLogs/commands/tailLogGroup.ts#L80).
However, currently the "mock response stream" in the test blocks
indefinitely on an [un-resolvable
promise](https://github.com/aws/aws-toolkit-vscode/blob/master/packages/core/src/test/awsService/cloudWatchLogs/commands/tailLogGroup.test.ts#L67).
So the test ends, and this finally block never triggers.

## Solution
Instead of using an un-resolving promise to keep the mock responseStream
open, use an AbortController. When the tests no longer need the
functionality of the disposables, the test can fire the AbortController.
This causes the stream to exit exceptionally, which triggers the
`finally` block in TailLogGroup and runs disposal.

This stops the event listeners from running after the test is completed,
and has eliminated the noisy logs. I have tested this by running `npm
run test` from the CLI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants