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

Block as needed inside core.App until started #560

Merged
merged 3 commits into from Nov 27, 2019
Merged

Conversation

@albrow
Copy link
Member

albrow commented Nov 27, 2019

Fixes #558.

As far as I can tell there is only one case where a field may not be fully initialized which can result in a nil pointer exception. All the issues we were seeing stem from this. The problem is that app.node is nil before app.Start is called (and sort of has to be because of how the libp2p works).

This PR fixes the issue by using a started channel inside of core.App to signal when app.node has been initialized. Any methods that depend on app.node will block by waiting to receive on the app.started channel. This can be easily extended to support other edge cases for any fields cannot be initialized until after Start is called.

albrow added 2 commits Nov 27, 2019
@albrow albrow requested a review from fabioberger Nov 27, 2019
@albrow

This comment has been minimized.

Copy link
Member Author

albrow commented Nov 27, 2019

Reminder to myself to add an entry to the CHANGELOG.

Copy link
Contributor

fabioberger left a comment

LGTM once CHANGELOG added

@albrow albrow changed the title Fix/async service start Block as needed inside core.App until initialized Nov 27, 2019
@albrow albrow changed the title Block as needed inside core.App until initialized Block as needed inside core.App until started Nov 27, 2019
@albrow albrow merged commit 289d7b3 into development Nov 27, 2019
1 of 2 checks passed
1 of 2 checks passed
ci/circleci: build CircleCI is running your tests
Details
continuous-integration/drone/push Build is passing
Details
@albrow albrow deleted the fix/async-service-start branch Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.