aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.44k stars 2.13k forks source link

events.closeAll does not really seem closing all the channels #13984

Closed tmokmss closed 1 week ago

tmokmss commented 2 weeks ago

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

GraphQL API

Amplify Version

v6

Amplify Categories

api

Backend

Other

Environment information

``` # Put output below this line ```

Describe the bug

events.closeAll does not seem workiing as expected. Even after calling the function, all the existing subscription remain active and new events are subscribed.

Expected behavior

After calling event.closeAll, all the existing channels are closed and no new events are subscribed.

Reproduction steps

Bascally I followed this tutorial: https://docs.aws.amazon.com/appsync/latest/eventapi/build-amplify-app.html#deploy-react-vite-app

But when I changed a line as below, channels will not be closed at all.

    return () => {
-      pr?.then((channel) => channel?.close())
+      events.closeAll()
    }

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

  {
    API: {
      Events: {
        endpoint: "https://redacted.appsync-api.us-west-2.amazonaws.com/event",
        defaultAuthMode: "apiKey",
        apiKey: "da2-redacted",
      },
    },
  };

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

chrisbonifacio commented 2 weeks ago

thank you for raising this issue! i've marked as a bug for the team.

we will look into it and report back with any progress on a fix.

iartemiev commented 1 week ago

@tmokmss - we published a bug fix for this issue to aws-amplify@unstable. It will be included in the next library release next week.

iartemiev commented 1 week ago

The bug fix has been released with aws-amplify@6.8.1.