Repository navigation
Dedupe inflation promise per activeRequests session - #94
lejeunerenard wants to merge 5 commits into
Conversation
If the shared node is cancelled in one, its cancelled in the other propagating the error. Caching is done via the `.inflating` property on the `TreeNodePointer` during `inflate()`.
Fixes the issue with sharing requests between `activeRequests` sessions potentially causing errors in unrelated streams.
Means that each session wont have their own requests as it will use the first request instead, but it will fallback to retrying with the next session if the original destroys the requests.
This allows inflating the keys & children to still be shared while not sending another request (because hypercore dedupes block requests). This fixes the previous commits test case where a 2nd stream hangs even when it is destroyed / cancelled. It previously would hang waiting on the cached promise from the first stream. Now it has its own request that will reject the promise.
|
This is particularly thorny because inflation can generate new requests using the current Hypercore's replicator itself handles varying concurrent timeouts correctly, but for that to work, each 'session' needs to make it's own requests via Hypercore (which also means each session needs to perform its own inflate as it might generate nested requests). That would make efforts to deduplicate inflation requests inside hyperbee2 very difficult. I don't think piggybacking on another session can be done correctly and instead hyperbee2's inflate should step in to manage its own If hyperbee2 did own |
Prior to the fix, the added test showed destroying stream
acausing an error in streamb. This is because the tree node would cache theinflatingpromise which then made requests shared across streams or other contexts.This fix tried to maintain the caching as much as possible from #60 (where the
inflatingpromise caching came from) by separating byactiveRequestssession. That keeps the sessions isolated. The original intent of #60 still needs to factored in however.Made with help from AI.