I have this same problem as this SO question (https://stackoverflow.com/questions/61389805/neo4jerror-run-from-within-the-transaction-or-use-a-different-session) but I am using neo4j 3.5.
I am getting this: Neo4jError: You cannot run more transactions on a closed session. I am not running any concurrent stuff. This happens on startup of my Nodejs server running on DigitalOcean. In my app.js I have two .js modules that access the neo4j DB to initialize two loki tables which always work fine for three years now and no recent changes have been made to those modules.
The nodejs server starts up fine but when I make an API call that access the DB, I use postman to test the API call (or from my Angular app), I get this error. All my neo4j calls uses the same pattern to close the session. I use the following pattern:
router.updateCountryTable = (data, callback) => {
commons.session.run(`WITH $paramCountry AS countries
UNWIND countries AS country
MATCH (c:Country) WHERE c.countryCurrencyCode = country[0]
SET c.baseCurrencyXrate = country[1], c.createdAt = $paramCreatedAt
RETURN c AS Countries`,
{
paramCountry: data,
paramCreatedAt: moment().format()
})
.then( result => {
commons.session.close();
if (!result.records[0]) {
return callback("error...there is no country in db");
}
// response = userData.records[0].get('user').properties;
return callback(null, result)
})
.catch((err) => callback(err.stack))
}
This is a stack trace of the error:
Neo4jError: You cannot run more transactions on a closed session.
7/29/2020 7:00:00 AM
7/29/2020 7:00:00 AM at captureStacktrace (/ng-app/node_modules/neo4j-driver/lib/v1/result.js:199:15)
7/29/2020 7:00:00 AM at new Result (/ng-app/node_modules/neo4j-driver/lib/v1/result.js:65:19)
7/29/2020 7:00:00 AM at Session._run (/ng-app/node_modules/neo4j-driver/lib/v1/session.js:154:14)
7/29/2020 7:00:00 AM at Session.run (/ng-app/node_modules/neo4j-driver/lib/v1/session.js:130:19)
7/29/2020 7:00:00 AM at Function.router.updateCountryTable (/ng-app/server/model/user.js:126:22)
7/29/2020 7:00:00 AM at /ng-app/server/model/pdmanagement.js:113:27
7/29/2020 7:00:00 AM at IncomingMessage.resp.on (/ng-app/server/model/user.js:95:18)
7/29/2020 7:00:00 AM at emitNone (events.js:111:20)
7/29/2020 7:00:00 AM at IncomingMessage.emit (events.js:208:7)
7/29/2020 7:00:00 AM at endReadableNT (_stream_readable.js:1064:12)
7/29/2020 7:00:00 AM at _combinedTickCallback (internal/process/next_tick.js:138:11)
7/29/2020 7:00:00 AM at process._tickCallback (internal/process/next_tick.js:180:9)
I am a lost because I don't get this error running the code from my local machine using the DB on DigitalOcean....only when I run the code on DigitalOcean.
Any ideas how I can solve this?