Skip to content

Commit eeeda23

Browse files
committed
fix: yield buf after reading length to make it safe to use with worker transfer
1 parent 45a80ee commit eeeda23

File tree

1 file changed

+8
-6
lines changed
  • packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content

1 file changed

+8
-6
lines changed

packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,17 @@ const fileContent = (cid, node, unixfs, path, resolve, depth, blockstore) => {
153153
let read = 0
154154

155155
for await (const buf of queue) {
156-
if (buf != null) {
157-
yield buf
156+
if (buf == null) {
157+
continue
158+
}
158159

159-
read += buf.byteLength
160+
read += buf.byteLength
160161

161-
if (read === length) {
162-
queue.end()
163-
}
162+
if (read === length) {
163+
queue.end()
164164
}
165+
166+
yield buf
165167
}
166168
}
167169

0 commit comments

Comments
 (0)