How to reset the lock file programmatically in ipfs 0.41.1

My app has a simple method to retrieve content with CID passed in (node 12.16.0 on windows10). Here is the method:

retrieveFromIpfs: async function(cid) {

const ipfs_node = await IPFS.create();

try {

    const fileBuffer = await ipfs_node.cat(cid)

    return fileBuffer;

} catch(err) {

    console.log("Error retrieving file from IPFS : ", err);

    return '';

}

}

The app saved a string of ā€œtest ipfs savingā€ to ipfs and retrieve it back with the CID:

//retrieve

router.post(ā€™/retrieveā€™, [], async (req, res) => {

try {

    const  data = await helper.retrieveFromIpfs(req.cid)

    console.log("ipfs data retrieved : ", data.toString());

    return data;  

} catch (err) {

    console.log("error in retrieving ipfs file ", err);

    return res.status(400).send(err.message);

}

} )

First time it returns Object [AsyncGenerator] {}. If try 2nd time, then there is file locked error.
Here is the error on the node console:

Listening on port 3000ā€¦
Executing (default): SELECT 1+1 AS result
DB connection has been established successfully.
Swarm listening on /ip4/192.168.1.6/tcp/4002/p2p/QmVxfGtbh95P1yiNVL9TmEm1tZm7SjcFbLo6UbG6SEfHJc
Swarm listening on /ip4/127.0.0.1/tcp/4002/p2p/QmVxfGtbh95P1yiNVL9TmEm1tZm7SjcFbLo6UbG6SEfHJc
Swarm listening on /ip4/127.0.0.1/tcp/4003/ws/p2p/QmVxfGtbh95P1yiNVL9TmEm1tZm7SjcFbLo6UbG6SEfHJc
ipfs data retrieved : Object [AsyncGenerator] {}
error in retrieving ipfs file Error: Lock file is already being held
at C:\d\code\js\emps_bbone\node_modules\proper-lockfile\lib\lockfile.js:68:47
at callback (C:\d\code\js\emps_bbone\node_modules\graceful-fs\polyfills.js:295:20)
at FSReqCallback.oncomplete (fs.js:167:5) {
code: ā€˜ELOCKEDā€™,
file: ā€˜C:\Users\JunC\.jsipfsā€™
}

Here is the example code followed on github: https://github.com/indreklasn/ipfs-node-example/blob/master/index.js

Here is the portion of package.json:

ā€œdependenciesā€: {

"@hapi/joi": "^17.1.0",

"compression": "^1.7.4",

"cors": "^2.8.5",

"dotenv": "^8.2.0",

"express": "^4.17.1",

"express-async-errors": "^3.1.1",

"helmet": "^3.21.2",

"ipfs": "^0.41.1",

"jsonwebtoken": "^8.5.1",

"moment": "^2.24.0",

"moment-timezone": "^0.5.27",

"nexmo": "^2.6.0",

"nodemon": "^2.0.2",

"pg": "^7.18.2",

"pg-hstore": "^2.3.3",

"randomstring": "^1.1.5",

"sequelize": "^5.21.5",

"socket.io": "^2.3.0",

"winston": "^3.2.1"

},

Hi @emclab js-ipfs recently moved to an streaming api with async iterable more info here https://blog.ipfs.io/2020-02-13-js-ipfs-0-41/ for your specific case you need to consume the async generator more info in the docs here https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#cat

If you have any more questions feel free to ping us again.

Many thanks. There is another ipfs example showing use all to assemble the iterables to form a data stream. Also after calling node.stop() when closing, the file locked error disappeared.