Skip to content

Commit 82f0c39

Browse files
authored
Only poll for graph schema when we dont have too many labels/relTypes (#646)
1 parent 8f09705 commit 82f0c39

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

.changeset/curvy-geckos-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@neo4j-cypher/query-tools': patch
3+
---
4+
5+
Workaround bug: Running db.schema.visualization on db with too large schema can crash db

packages/query-tools/src/metadataPoller.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,18 @@ export class ConnectedMetadataPoller extends MetadataPoller {
250250
await Promise.allSettled([
251251
this.databases.refetch(),
252252
this.dataSummary.refetch(),
253-
this.graphSchema.refetch(),
254253
...Object.values(this.procedures).map((version) => version?.refetch()),
255254
...Object.values(this.functions).map((version) => version?.refetch()),
256255
]);
256+
if (
257+
this.dbSchema.labels &&
258+
this.dbSchema.relationshipTypes &&
259+
this.dbSchema.labels.length + this.dbSchema.relationshipTypes.length < 200
260+
) {
261+
await this.graphSchema.refetch();
262+
} else {
263+
this.dbSchema.graphSchema = undefined;
264+
}
257265
this.events.emit('schemaFetched');
258266
}
259267

packages/query-tools/src/neo4jConnection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export class Neo4jConnection {
167167
const result = tx.run(query, {});
168168
return await queryConfig.resultTransformer(result);
169169
},
170-
{ metadata: { ...METADATA_BASE, type: queryType } },
170+
{ timeout: 500, metadata: { ...METADATA_BASE, type: queryType } },
171171
);
172172
} finally {
173173
await session.close();

0 commit comments

Comments
 (0)