Skip to content

Amplify PubSub unsubscribe method does not report the status/complete before sign out?  #9805

@entest-hai

Description

@entest-hai

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

PubSub

Amplify Categories

Not applicable

Environment information

I am using [Amplify PubSub to subscribe to an IoT topic ](https://docs.amplify.aws/lib/pubsub/subunsub/q/platform/js/#subscribe-to-a-topic). I want to stop/unsubscribe before sign out. However, there is no mechanism to check/ensure that unsubscribe completed before sign out.  


Describe the bug

Sign out happens before unsubscribe completed, therefore, the client (web browser) still subscribe the IoT topic even after sign out.

Expected behavior

The unsubscribe method of PubSub should has a mechanism to inform the status of unsubscribe

Reproduction steps

https://docs.amplify.aws/lib/pubsub/subunsub/q/platform/js/#subscribe-to-a-topic

Code Snippet

const sub1 = PubSub.subscribe('myTopicA').subscribe({
    next: data => console.log('Message received', data),
    error: error => console.error(error),
    complete: () => console.log('Done'),
});

sub1.unsubscribe();
// You will no longer get messages for 'myTopicA'

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

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

Metadata

Metadata

Assignees

Labels

PubSubRelated to PubSub categorybugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions