Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

fix: await pubsub unsubscribe to fix flaky test #3755

Closed
wants to merge 1 commit into from

Conversation

achingbrain
Copy link
Member

We manage pubsub subscriptions locally in the http client, when we unsubscribe from a given topic, we abort the long-lived connection we're holding open but do not wait for it to actually close.

In our tests we unsubscribe then check the subscription list - if we do this before the subscription is torn down it can report that we are still subscribed to the topic we just unsubscribed from.

The fix here is to wait for the connection to be torn down before returning from the unsubscribe call, by which point we should no longer have the topic in our subs list.

We manage pubsub subscriptions locally in the http client, when we unsubscribe
from a given topic, we abort the long-lived connection we're holding open but
do not wait for it to actually close.

In our tests we unsubscribe then check the subscription list - if we do this
before the subscription is torn down it can report that we are still subscribed
to the topic we just unsubscribed from.

The fix here is to wait for the connection to be torn down before returning
from the unsubscribe call, by which point we should no longer have the topic
in our subs list.
@achingbrain
Copy link
Member Author

Fixes this sort of error:

ipfs:   1) interface-ipfs-core over ipfs-http-client tests against go-ipfs
ipfs:        .pubsub.unsubscribe
ipfs:          should subscribe and unsubscribe 5 times:
ipfs:       AssertionError: expected [ Array(1) ] to deeply equal []
ipfs:       + expected - actual
ipfs:       -[
ipfs:       -  "pubsub-tests-fAnzZgkOvVVMyDEl9ewm8"
ipfs:       -]
ipfs:       +[]
ipfs:       
ipfs:       at file:///home/travis/build/ipfs/js-ipfs/node_modules/chai-as-promised/lib/chai-as-promised.js:302:22

@achingbrain achingbrain marked this pull request as draft July 20, 2021 11:29
@achingbrain
Copy link
Member Author

Bleugh, didn't fix it, needs more investigation.

@achingbrain
Copy link
Member Author

Superseded by #3761

@achingbrain achingbrain deleted the fix/await-pubsub-unsubscribe branch July 27, 2021 09:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant