fix: stop popup hang on failed DAG resolution#1390
Open
lidel wants to merge 3 commits into
Open
Conversation
The browser-action popup resolved a tab's CID and immutable path with a live ipfs.resolve() call and no error handling. When that call rejected or hung, the result cache was never written and the follow-up render never ran, so the CID, immutable-path and permalink rows stayed on the "(waiting for DAG data)" placeholder forever. Guard the resolution with a 15s timeout and a try/catch. On failure, cache the error briefly (3s) so the rows show an "unavailable" hint instead of spinning, retries stay paced by the popup poll rather than looping, and a recovered node is picked up on the next poll. Closes #1334
p-memoize v8 ignores the maxAge option, so resolveToCid and resolveToImmutableIpfsPath memoized results in a plain Map that never expired. Both come from mutable IPNS/DNSLink lookups whose target can change, so a stale CID could be shown for the whole service-worker lifetime. Back the memoization with an LRU cache capped at 1 minute.
Extend the existing distrust note to x-ipfs-roots and spell out that neither header may be read to shortcut work like the popup's Copy CID; resolve through the IPFS node instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
On an IPNS or DNSLink page, opening the browser-action popup could leave the Copy CID, immutable-path, and permalink rows stuck on
(waiting for DAG data)forever. The rows are filled by a liveipfs.resolve()call with no error handling, so if that call rejected or hung, the result was never cached and the follow-up render never ran. Making it worse,p-memoizev8 ignoresmaxAge, so resolved CIDs were memoized in a plain Map that never expired, and a stale CID could show for the whole service-worker lifetime.Fix
Guard the resolution with a 15s timeout and a try/catch; on failure show an
unavailablehint and retry on the next poll instead of spinning.Back the CID/path memoization with an LRU cache capped at 1 minute (mutable IPNS/DNSLink targets can change;
ipfs.resolve()does not expose the record TTL).Closes error: Waiting for DAG data in main menu #1334