neo4j-javascript-driver
neo4j-javascript-driver copied to clipboard
Running an array of cypher queries with Promise.all hangs
trafficstars
I have created a service to run Cypher query and hen I call this service in an array to Promise.all. Promise.all works efficiently until 6 sets of queries but as it exceeds it hangs. No response!
Service query looks like this:
async function run(queryObj){
try{
var session=db.session();
const txc = session.beginTransaction();
try{
queryObj.params=convert.NumToint(queryObj.params);
let result= await txc.run(queryObj.query,queryObj.params);
let status=await txc.commit();
let data=[];
result.records.forEach(record=>{
let element={};
let len=record.length;
let keys=record.keys;
for(let i=0;i<len;i++){
element[keys[i]]=record.get(keys[i]);
}
data.push(convert.Map(element));
})
return data;
} catch(err){
await txc.rollback();
throw err;
} finally {
await session.close();
}
} catch(err){
console.log(err);
throw err;
}
}
@sureshrajan8 This looks like you are committing the transaction before consuming the query result inside it. You should refactor your code to consume the result first, before committing.
Closed due long inactive. This issue could be re-opened if needed.