-
-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: light-client start should never block #6619
Conversation
e00df19
to
62db411
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## unstable #6619 +/- ##
============================================
- Coverage 61.61% 61.60% -0.01%
============================================
Files 556 556
Lines 58566 58569 +3
Branches 1859 1859
============================================
Hits 36084 36084
- Misses 22441 22444 +3
Partials 41 41 |
Performance Report✔️ no performance regression detected Full benchmark results
|
packages/light-client/src/index.ts
Outdated
void this.runLoop(); | ||
|
||
return startPromise; | ||
return this.runLoop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem I see in this approach is that normally user will use await client.start()
, that will block the event loop forever.
The syntax void this.runLoop()
is a way to put the run loop in the background so the await client.start()
does not block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, so I guess the previous approach made more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just check if light client is already started and return right away when start()
is called? The second start call should be a no-op
62db411
to
cf47a84
Compare
🎉 This PR is included in v1.18.0 🎉 |
Motivation
light-client
start should never block.Description
Currently, calling
light-client
start twice in a row will wait forever.Simplify the wait logic by leveraging the fact that
runLoop
already awaits forstarted
state.