Comments (8)
Hey, any news on that? Thanks!
from neo4j-javascript-driver.
Hi, would it be possible to get some insight on this? Thanks!
from neo4j-javascript-driver.
Hi @gchicoye, do you have some logs or an minimal example?
You can enable the logs by creating the driver with:
const driver = neo4j.driver(<your url>, <your credentials>, {
...// other configurations,
logging: neo4j.logging.console("debug")
})
See:
https://neo4j.com/docs/api/javascript-driver/5.9/function/index.html#static-function-driver
from neo4j-javascript-driver.
Hi @gchicoye, do you have some logs or an minimal example?
You can enable the logs by creating the driver with:
const driver = neo4j.driver(<your url>, <your credentials>, { ...// other configurations, logging: neo4j.logging.console("debug") })See: https://neo4j.com/docs/api/javascript-driver/5.9/function/index.html#static-function-driver
I get a TS error here...
Property 'logging' does not exist on type '{ driver: (url: string, authToken?: AuthToken | undefined, config?: Config | undefined) => Driver; hasReachableServer: (url: string, config?: Pick<Config, "logging"> | undefined) => Promise<...>; ... 68 more ...; notificationFilterMinimumSeverityLevel: EnumRecord<...>; }'.ts(2339)
from neo4j-javascript-driver.
Hi, any idea on this?
from neo4j-javascript-driver.
Can you try to ignore the ts definition?
const driver = neo4j.driver(<your url>, <your credentials>, {
...// other configurations,
// @ts-ignore
logging: neo4j.logging.console("debug")
})
I will investigate the ts type error.
from neo4j-javascript-driver.
Hey,
Done !
I've done a lot of updates on my code, now it looks like the following
const upsertDbEntry = async (dbEntry:DbEntry, txc:Transaction)
:Promise<QueryResult> => txc.run(
`
MERGE (user:User{first_id: $userId })
ON CREATE SET user.created_at = timestamp()
ON MATCH SET user.updated_at = timestamp()
MERGE (audience:Audience{mediarithmics_id: $segmentId })
ON CREATE SET audience.created_at = timestamp()
ON MATCH SET audience.updated_at = timestamp()
MERGE (user)-[rel:BELONGS_TO]->(audience)
ON CREATE SET rel.created_at = timestamp()
`,
dbEntry,
);
const deleteDbEntry = async (dbEntry:DbEntry, txc:Transaction)
:Promise<QueryResult> => txc.run(
`MATCH (user:User{first_id:$userId})-[belong:BELONGS_TO]->(audience:Audience{mediarithmics_id: $segmentId})
DELETE belong`,
dbEntry,
);
export const saveChunkData = async (dbEntries:DbEntry[]):Promise<boolean> => {
const session = driver.session();
const txc = session.beginTransaction();
try {
for (let i = 0; i < dbEntries.length; i += 1) {
const dbEntry = dbEntries[i];
if (dbEntry.action === 'UPSERT') upsertDbEntry(dbEntry, txc);
if (dbEntry.action === 'DELETE') deleteDbEntry(dbEntry, txc);
mediarithmicsLinesCounter.inc();
}
await txc.commit();
return true;
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
await txc.rollback();
// eslint-disable-next-line no-console
console.log('rolled back');
return false;
} finally {
await session.close();
}
};
export const saveChunkDataWithRace = async (dbEntries:DbEntry[]):Promise<void> => {
const endPromise:Promise<boolean> = new Promise((resolve) => {
setTimeout(() => {
resolve(false);
}, 60000);
});
const promises:Promise<boolean>[] = [
saveChunkData(dbEntries),
endPromise,
];
const result = await Promise.race(promises);
if (!result) {
// eslint-disable-next-line no-console
console.log(`${new Date().toString()} - Commit timeout`);
process.exit(1);
}
};
I get the following logs from debug (the ts-ignore
trick made the job :))
1687880367930 DEBUG Connection [0][bolt-2411] C: RUN
MERGE (user:User{first_id: $userId })
ON CREATE SET user.created_at = timestamp()
ON MATCH SET user.updated_at = timestamp()
MERGE (audience:Audience{mediarithmics_id: $segmentId })
ON CREATE SET audience.created_at = timestamp()
ON MATCH SET audience.updated_at = timestamp()
MERGE (user)-[rel:BELONGS_TO]->(audience)
ON CREATE SET rel.created_at = timestamp()
{"action":"UPSERT","userId":"7c5c2e7fb4cb4eba77e2daa02a4ce301","segmentId":"36595"} {}
1687880367930 DEBUG Connection [0][bolt-2411] C: PULL {"n":{"low":1000,"high":0}}
1687880367932 DEBUG Connection [0][bolt-2411] S: SUCCESS {"signature":112,"fields":[{}]}
However, I usually cannot get the commit to perform, and so nothing happens, my timeout function is executed (nothings happens for minutes otherwise) and container restarts...
from neo4j-javascript-driver.
You should resolve the promise returned by the tx.run. You can do by:
if (dbEntry.action === 'UPSERT') await upsertDbEntry(dbEntry, txc);
if (dbEntry.action === 'DELETE') await deleteDbEntry(dbEntry, txc);
from neo4j-javascript-driver.
Related Issues (20)
- time consumed in neo4j browser for a query is ~20ms, while using the driver facing a huge increase in time ~370ms. HOT 3
- Impossible to connect to Aura-hosted database HOT 2
- Error connecting Neo4j 5.6 with neo4j-driver-bolt-connection 5.8.0 HOT 1
- Different situations on different browser HOT 2
- [Bug] `parseDatabaseUrl` removes path from URL HOT 12
- Datetime function timezone issue HOT 2
- Fatal JavaScript out of memory: Ineffective mark-compacts near heap limit HOT 1
- [HELP] Type 'T' does not satisfy the constraint 'Dict'. HOT 4
- ypeError: Cannot read properties of undefined (reading 'startsWith') HOT 2
- sessionExpired errors when using the driver from nodeJS to aura HOT 7
- :auto statement not working HOT 2
- Routing table never fresh with null (default) database name HOT 1
- Connection attempts time out when connecting using Bun HOT 7
- How to disable wss request,just use ws HOT 1
- Routing Table/ Connection Timed out error HOT 5
- Add release notes to Github releases HOT 3
- Enabling node.js source maps increases neo4j-driver total execution time by 70x+ on my machine HOT 4
- Driver Performance HOT 5
- Memory leak in transactions with many queries HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neo4j-javascript-driver.