Open ztratar opened 6 months ago
Thanks for the report @ztratar, which driver and node versions are you using?
I don't have issue with my simple esbuild setup here:
package.json
{
"name": "gh1168",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"esbuild": "^0.19.11"
},
"dependencies": {
"neo4j-driver": "^5.16.0"
},
"scripts": {
"build": "esbuild index.js --bundle --platform=node --sourcemap --outfile=bin/out.js"
}
}
index.js
const neo4j = require('neo4j-driver')
const driver = neo4j.driver('neo4j://localhost:7687', neo4j.auth.basic('neo4j', 'password'))
performance.measure('Start to Now');
performance.mark('Before Query');
driver.executeQuery('RETURN 1', {}, {
database: 'neo4j'
}).then(() => {
performance.mark('After Query')
const measure = performance.measure('Query Time', 'Before Query', 'After Query');
console.log('Query took', measure.duration)
}).finally(() => driver.close())
Command line:
yarn build && node bin/out.js
Hello! This was happening on 16.19.
We've now upgraded to node 20 LTS, and, oddly enough, it appears the query times have all improved to normal with that change.
I've tried my sample with project with node v16.19.0
and I can't reproduce the problem.
I can't figure out what's happening. Can you reproduce the problem with the setup I shared?
Thanks
When i run neo4j in my node.js app, if
--enable-source-maps
is enabled, the average query time moves from 10ms to over a second.Some more details:
We have a node.js backend application. When I run in using
yarn dev
(e.g.DEBUG=backend* node --enable-source-maps build.js --start --watch"
)All queries and operations take about a second minimum.
When I then build that javascript app
"rm -rf dist && NODE_ENV=development node build.js
And then run dist/index.js.. boom, 1 second turns to 7ms.For building I am using esbuild. When I run a hybrid
node build.js --start --watch
manually... even though I'm watching as in normal dev mode, the query time remains performant.I've been able to narrow this down to purely source maps. I don't know why source maps should affect neo4j query performance, but I would like to have them enabled and still be able to run development with speedy queries.