From f9dbde9fa1220d44e4647a64227738ed71d0205b Mon Sep 17 00:00:00 2001 From: NoahMaizels Date: Tue, 31 Mar 2026 15:34:50 +0700 Subject: [PATCH 1/2] fix: add timing delay in feed write/read inline snippets The Bee node needs ~1 second to index a feed SOC chunk after writer.upload() before reader.downloadReference() can find it. Matches the same fix already applied to script-02.js in the ethersphere/examples repo (PR #1). Co-Authored-By: Claude Sonnet 4.6 --- docs/develop/dynamic-content.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/develop/dynamic-content.md b/docs/develop/dynamic-content.md index 73ccc5c6..0db974ae 100644 --- a/docs/develop/dynamic-content.md +++ b/docs/develop/dynamic-content.md @@ -184,6 +184,9 @@ const writer = bee.makeFeedWriter(topic, pk); await writer.upload(batchId, upload.reference); console.log("Feed updated at index 0"); +// Brief pause to allow the node to index the feed chunk +await new Promise((r) => setTimeout(r, 1000)); + // Read the latest reference from the feed const reader = bee.makeFeedReader(topic, owner); const result = await reader.downloadReference(); @@ -229,6 +232,9 @@ console.log("New content hash:", upload2.reference.toHex()); await writer.upload(batchId, upload2.reference); console.log("Feed updated at index 1"); +// Brief pause to allow the node to index the feed chunk +await new Promise((r) => setTimeout(r, 1000)); + // Reading the feed now returns the updated reference const result2 = await reader.downloadReference(); console.log("Latest reference:", result2.reference.toHex()); From 524ab1dc41c30307568e421b39efac98d9440015 Mon Sep 17 00:00:00 2001 From: NoahMaizels Date: Fri, 3 Apr 2026 06:50:39 +0700 Subject: [PATCH 2/2] fix: sync inline bee-js snippets with script-02.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace setTimeout delay with retryFeedRead in Write and Read snippet - Replace setTimeout delay with retryFeedRead + minFeedIndex in Update the Feed snippet - Fix feed print description to match actual swarm-cli output (topic hash, number of updates, and feed manifest URL — not the raw Swarm reference) Co-Authored-By: Claude Sonnet 4.6 --- docs/develop/dynamic-content.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/develop/dynamic-content.md b/docs/develop/dynamic-content.md index 0db974ae..197f2e83 100644 --- a/docs/develop/dynamic-content.md +++ b/docs/develop/dynamic-content.md @@ -184,12 +184,10 @@ const writer = bee.makeFeedWriter(topic, pk); await writer.upload(batchId, upload.reference); console.log("Feed updated at index 0"); -// Brief pause to allow the node to index the feed chunk -await new Promise((r) => setTimeout(r, 1000)); -// Read the latest reference from the feed +// Read the latest reference from the feed (retries until indexed) const reader = bee.makeFeedReader(topic, owner); -const result = await reader.downloadReference(); +const result = await retryFeedRead(() => reader.downloadReference()); console.log("Latest reference:", result.reference.toHex()); console.log("Current index:", result.feedIndex.toBigInt()); ``` @@ -210,7 +208,7 @@ swarm-cli feed print \ --topic-string notes ``` -The `feed print` command displays the current feed state, including the Swarm reference it points to and the feed manifest URL. +The `feed print` command displays the current feed state — topic hash, number of updates, and the feed manifest URL. @@ -232,11 +230,12 @@ console.log("New content hash:", upload2.reference.toHex()); await writer.upload(batchId, upload2.reference); console.log("Feed updated at index 1"); -// Brief pause to allow the node to index the feed chunk -await new Promise((r) => setTimeout(r, 1000)); -// Reading the feed now returns the updated reference -const result2 = await reader.downloadReference(); +// Pass minFeedIndex so the retry waits for the new entry, not just any entry. +const result2 = await retryFeedRead( + () => reader.downloadReference(), + result.feedIndex.toBigInt() + 1n +); console.log("Latest reference:", result2.reference.toHex()); console.log("Current index:", result2.feedIndex.toBigInt()); // 1n ``` @@ -807,7 +806,7 @@ const topic = Topic.fromString(cfg.topic); const owner = new EthAddress(cfg.owner); const reader = bee.makeFeedReader(topic, owner); -const result = await reader.downloadReference(); +const result = await retryFeedRead(() => reader.downloadReference()); console.log("Latest content reference:", result.reference.toHex()); console.log("Feed index:", result.feedIndex.toBigInt()); console.log("View:", `${process.env.BEE_URL}/bzz/${cfg.manifest}/`);