Skip to content

Conversation

@Marketen
Copy link
Contributor

@Marketen Marketen commented Sep 5, 2025

  • retry if something goes wrong when fetching CAR up to 3 times
  • ask for whole DAG instead of only the root CID (should fix "could not get block" errors)

@Marketen Marketen requested a review from Copilot September 5, 2025 17:05
@Marketen Marketen self-assigned this Sep 5, 2025
@Marketen Marketen requested a review from a team as a code owner September 5, 2025 17:05
@github-actions github-actions bot temporarily deployed to commit September 5, 2025 17:05 Inactive
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the IPFS data fetching mechanism by implementing retry logic and requesting complete DAG structures instead of just root CIDs to improve reliability.

  • Adds retry logic with up to 3 attempts when fetching CAR data from IPFS
  • Changes the request to fetch entire DAG structures using dag-scope=all&order=dfs parameters
  • Introduces debug logging to track block counts and child block presence

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 443 to 451
let blockCount = 0;
let hasChildren = false;
for await (const { cid } of carReader.blocks()) {
blockCount++;
if (!cid.equals(root)) hasChildren = true;
}
console.debug(
`[IPFS] CAR stats: blocks=${blockCount} hasChildren=${hasChildren}`
);
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The block iteration for logging purposes adds unnecessary overhead on every successful request. Consider moving this debug logging behind a debug flag or removing it entirely, as it iterates through all blocks just for logging.

Suggested change
let blockCount = 0;
let hasChildren = false;
for await (const { cid } of carReader.blocks()) {
blockCount++;
if (!cid.equals(root)) hasChildren = true;
}
console.debug(
`[IPFS] CAR stats: blocks=${blockCount} hasChildren=${hasChildren}`
);
if (process.env.DEBUG) {
let blockCount = 0;
let hasChildren = false;
for await (const { cid } of carReader.blocks()) {
blockCount++;
if (!cid.equals(root)) hasChildren = true;
}
console.debug(
`[IPFS] CAR stats: blocks=${blockCount} hasChildren=${hasChildren}`
);
}

Copilot uses AI. Check for mistakes.
} catch (e) {
lastError = e;
// Wait a bit before retrying
if (attempt < 2) await new Promise(r => setTimeout(r, 500));
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The magic number 500 (milliseconds) should be defined as a named constant to improve readability and maintainability.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Sep 5, 2025

@github-actions github-actions bot temporarily deployed to commit September 5, 2025 17:34 Inactive
@github-actions
Copy link

github-actions bot commented Sep 5, 2025

Dappnode bot has built and pinned the built packages to an IPFS node, for commit: d9c2755

This is a development version and should only be installed for testing purposes.

  1. Package dappmanager.dnp.dappnode.eth

Install link

Hash: /ipfs/QmP4jzsKbf4kjV95bSSyLYScbPB6RhQWSTx1KRuUCSfRm6

(by dappnodebot/build-action)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants