Skip to content

Commit

Permalink
fix: attempt to use peek.. doesnt seem to help
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Dec 10, 2024
1 parent ffa2d62 commit 2f9d495
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/verified-fetch/src/utils/enhanced-dag-traversal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type ComponentLogger } from '@libp2p/interface'
import { type ReadableStorage, exporter, type ExporterOptions } from 'ipfs-unixfs-exporter'
import first from 'it-first'
// import peekable from 'it-peekable'
import peekable from 'it-peekable'
import toBrowserReadableStream from 'it-to-browser-readablestream'
import { type CID } from 'multiformats/cid'
import { type ContentTypeParser } from '../types.js'
Expand Down Expand Up @@ -50,7 +50,14 @@ export async function enhancedDagTraversal ({
let error: Error
try {
// Fetch the first chunk eagerly
firstChunk = await first(dfsIter)
const peekableIter = peekable(dfsIter)
const firstPeek = await peekableIter.peek()
if (firstPeek.done === true) {
throw new Error('No content found')
}
// firstChunk = await first(dfsIter)
firstChunk = firstPeek.value
peekableIter.push(firstChunk)
} catch (err: any) {
if (signal?.aborted === true) {
error = err
Expand Down

0 comments on commit 2f9d495

Please sign in to comment.