Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
ssb-meta-feeds
findByIdSync
is used in the new ssb-ebt ssbc/ssb-ebt#52 which in turn is used in ssbc/ssb-replication-scheduler#5 .Problem
We bumped into a race condition where there are two pull.drains on meta feed messages: (A) one in ssb-meta-feeds
feeds-lookup.js
(to keep track of the "details" object associated which each (foreign or local) subfeed ID) and (B) another one inssb-replication-scheduler
to trigger the replication of a subfeed. We realized that the processing in (A) for a specific subfeed ID must happen before the respective processing in (B) because information calculated in (A) will be needed by ssb-ebt once (B) calls into ssb-ebt APIs.Solution
New API
ensureLoaded(feedId, cb)
similar toloadState(cb)
, but for a specificfeedId
.While
loadState(cb)
just kicks off the pull.drain for all possible meta feed msgs,ensureLoaded()
will wait until the specificfeedId
has been processed by the nextupdateLookup()
.This should be one of the pieces of the puzzle to solve the Problem described above, we will also need a few changes in ssb-ebt to fully solve it.