Skip to content

client.destroy() does not stop a CloudWatch Logs Live Tail session #6392

@mnapoli

Description

@mnapoli

Checkboxes for prior research

Describe the bug

The documentation states that a Logs live tail session can be stopped by calling client.destroy(): https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/example_cloudwatch-logs_StartLiveTail_section.html

    const client = new CloudWatchLogsClient();

    const command = new StartLiveTailCommand({
        logGroupIdentifiers: logGroupIdentifiers,
        logStreamNames: logStreamNames,
        logEventFilterPattern: filterPattern
    });
    try{
        const response = await client.send(command);
        handleResponseAsync(response);
    } catch (err){
        // Pre-stream exceptions are captured here
        console.log(err);
    }

    /* Set a timeout to close the client. This will stop the Live Tail session. */
    setTimeout(function() {
        console.log("Client timeout");
        client.destroy();
      }, 10000);

However that doesn't work, the session still runs.

I think this is the same problem as #3922 with the Transcribe client. This issue was fixed in #4400 by adding code in destroy().

If we look at the code, the destroy() method doesn't do anything:

destroy(): void {
super.destroy();
}

SDK version number

"@aws-sdk/client-cloudwatch-logs": "^3.632.0"

Which JavaScript Runtime is this issue in?

Browser

Details of the browser/Node.js/ReactNative version

Chrome

Reproduction Steps

    const client = new CloudWatchLogsClient();

    const command = new StartLiveTailCommand({
        logGroupIdentifiers: logGroupIdentifiers,
        logStreamNames: logStreamNames,
        logEventFilterPattern: filterPattern
    });
    try{
        const response = await client.send(command);
        handleResponseAsync(response);
    } catch (err){
        // Pre-stream exceptions are captured here
        console.log(err);
    }

    /* Set a timeout to close the client. This will stop the Live Tail session. */
    setTimeout(function() {
        console.log("Client timeout");
        client.destroy();
      }, 10000);

Observed Behavior

The async function is still called, the HTTP request is not closed.

Expected Behavior

The HTTP request is closed and the async function no longer receives events.

Possible Solution

No response

Additional Information/Context

I think this is the same problem as #3922 with the Transcribe client. This issue was fixed in #4400 by adding code in destroy().

If we look at the code, the destroy() method doesn't do anything:

destroy(): void {
super.destroy();
}

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions