IPFS Lock file getting in the way when making multiple calls

Hello, I’ve just started working with js-ipfs and have run into an error surrounding the lock file. I have this function that returns the content of JSON ipfs files, it works fine when I call it once, but when I try to call it twice I get this error:
Lock already being held for file: /Users/jackmanning/.jsipfs/repo.lock
at Object.exports.lock
at async IpfsRepo._openLock
at async IpfsRepo.open
at async openRepo
Here is my code:
async function getAttributes(ipfsLink) {
const node = await IPFS.create()
const stream = node.cat(ipfsLink);

let metadataStr = ''

for await (const chunk of stream) {
    // chunks of data are returned as a Buffer, convert it back to a string
    metadataStr += chunk
// gets data as object
const dataObj = JSON.parse(metadataStr);

// gets image, description, and name
const image = dataObj["image"];
const description = dataObj["description"];
const name = dataObj["name"];

// console.log('image: ', image)
// console.log('description: ', description)
// console.log('name: ', name)
const finalProduct = 
        "img": image,
        "title": name,
        "desc": description

return finalProduct;

Let me know if you have any solutions or if more information would be helpful.

I think maybe you just need something like this when you’re done:

await node.stop()
1 Like