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

Block as needed inside core.App until started #560

Merged
merged 3 commits into from
Nov 27, 2019

Conversation

albrow
Copy link
Contributor

@albrow 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
Copy link
Contributor Author

albrow commented Nov 27, 2019

Reminder to myself to add an entry to the CHANGELOG.

Copy link
Contributor

@fabioberger fabioberger left a comment

Choose a reason for hiding this comment

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

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
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.

2 participants