Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix pubsub subscribe #735

Merged
merged 20 commits into from Jan 5, 2021
Merged

Hotfix pubsub subscribe #735

merged 20 commits into from Jan 5, 2021

Conversation

v-stickykeys
Copy link
Contributor

@v-stickykeys v-stickykeys commented Dec 31, 2020

Motivation

Our ipfs node on infra is going down periodically (reason tbd) and when it reboots we stop receiving pubsub messages.
Created an issue on js-ipfs repo here ipfs/js-ipfs#3465 -- the error handler for pubsub is broken in Node.js

Changes

@v-stickykeys
Copy link
Contributor Author

This is actually breaking a lot of tests..
I think (1) because pubsub.ls is not mocked and (2) because it creates a new Node.js Timer with setInterval and requires dispatcher.close to be called to clean it up.

Because this is a hotfix anyway I'll see if I can modify some of the code to avoid a lot of test refactoring for now

Copy link
Member

@oed oed left a comment

Choose a reason for hiding this comment

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

Few comments.

packages/core/src/__tests__/dispatcher.test.ts Outdated Show resolved Hide resolved
packages/core/src/dispatcher.ts Outdated Show resolved Hide resolved
packages/core/src/dispatcher.ts Outdated Show resolved Hide resolved
packages/core/src/dispatcher.ts Outdated Show resolved Hide resolved
@v-stickykeys v-stickykeys requested a review from oed January 4, 2021 21:57
Copy link
Contributor

@stbrody stbrody left a comment

Choose a reason for hiding this comment

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

A few small nitpicks, but my main question is if we can avoid the logic that checks if we are subscribed and just always try to subscribe unconditionally.

packages/core/src/dispatcher.ts Outdated Show resolved Hide resolved
packages/core/src/dispatcher.ts Outdated Show resolved Hide resolved
packages/core/src/dispatcher.ts Outdated Show resolved Hide resolved
packages/core/src/dispatcher.ts Show resolved Hide resolved
packages/core/src/dispatcher.ts Outdated Show resolved Hide resolved
packages/core/src/dispatcher.ts Show resolved Hide resolved
packages/core/src/dispatcher.ts Outdated Show resolved Hide resolved
Co-authored-by: Spencer T Brody <spencer@3box.io>
@v-stickykeys
Copy link
Contributor Author

v-stickykeys commented Jan 5, 2021

@stbrody yeah as joel mentioned it throws an error that you are already subscribed. But agree it's probably worth just doing that in case the ls returns unexpected results (which it has in certain conditions like if the node has already attempted to subscribe before the client has).

Copy link
Member

@oed oed left a comment

Choose a reason for hiding this comment

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

Looks good, just one Q

packages/core/src/dispatcher.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@stbrody stbrody left a comment

Choose a reason for hiding this comment

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

Nice! This looks much cleaner. LGTM mod one comment about making sure the console doesn't fill with errors when everything is actually working as expected

@v-stickykeys v-stickykeys merged commit ed4c6a0 into develop Jan 5, 2021
@v-stickykeys v-stickykeys deleted the hotfix/pubsub-subscribe branch January 5, 2021 20:54
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.

None yet

3 participants