Closed Jollarvia closed 3 months ago
The issue here is with how you're using the helia.pins.add method, which has changed in Helia 3.x.x.
Before:
const cid = CID.parse('QmFoo')
await helia.pin.add(cid)
After (with an AsyncGenerator):
const cid = CID.parse('QmFoo')
for await (const pinnedCid of helia.pins.add(cid)) {
// ...
}
In your test, you're using the helia.pins.add method with a single parameter (cid) and then trying to iterate over the result using a for...in loop. However, since add now returns an AsyncGenerator, you should use a for await...of loop instead.
change this code:
var pre = await helia.pins.add(cid)
for (var x in pre){
console.log(JSON.stringify(pre))
}
to
// Use the AsyncGenerator to pin the CID
for await (const pinnedCid of helia.pins.add(cid)) {
console.log(`Pinned CID: ${pinnedCid}`);
}
It should work now!
Thanks @acul71 , that fixed it. Closing the issue.
I have a test in my software that broke the moment I moved from 2.3.0 to 4.2.1. So I created a mocha test with pure Helia to illustrate my problem.
The object is retrievable from the datastore. The generator recovered from the act of pinning ('variable name pre') does not have the passed in cid and ispinned always returns false. I would expect it to be true as it was in 2.3.0.