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

    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’/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/
Swarm listening on /ip4/
Swarm listening on /ip4/
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:

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",

"": "^2.3.0",

"winston": "^3.2.1"


Hi @emclab js-ipfs recently moved to an streaming api with async iterable more info here for your specific case you need to consume the async generator more info in the docs here

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.