Skip to content

Commit

Permalink
Fix: Don’t run meta query on system db
Browse files Browse the repository at this point in the history
The `Observable.if` doesn’t execute one or the other path, it only make the decision on what to subscribe to.
So both paths was actually executed, all the time.
This fixes that.
  • Loading branch information
oskarhane committed May 4, 2020
1 parent 2ca4cb1 commit d22d3c4
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions src/shared/modules/dbMeta/dbMetaDuck.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,33 +315,28 @@ export const dbMetaEpic = (some$, store) =>
.mergeMap(() =>
Rx.Observable.forkJoin([
// Labels, types and propertyKeys, and server version
Rx.Observable.if(
() => {
const state = store.getState()
const db = getUseDb(state)
const isSystem = db === SYSTEM_DB
if (isSystem) {
store.dispatch(updateMeta([]))
}
return isSystem
},
Rx.Observable.of(null),
Rx.Observable.fromPromise(
bolt
.routedReadTransaction(
metaQuery,
{},
{
useCypherThread: shouldUseCypherThread(
store.getState()
),
onLostConnection: onLostConnection(store.dispatch),
...getBackgroundTxMetadata({
hasServerSupport: canSendTxMetadata(store.getState())
})
}
)
.catch(() => {})
Rx.Observable.of(null).mergeMap(() => {
const db = getUseDb(store.getState())

// System db, do nothing
if (db === SYSTEM_DB) {
store.dispatch(updateMeta([]))
return Rx.Observable.of(null)
}

// Not system db, try and fetch meta data
return Rx.Observable.fromPromise(
bolt.routedReadTransaction(
metaQuery,
{},
{
useCypherThread: shouldUseCypherThread(store.getState()),
onLostConnection: onLostConnection(store.dispatch),
...getBackgroundTxMetadata({
hasServerSupport: canSendTxMetadata(store.getState())
})
}
)
)
.do(res => {
if (res) {
Expand All @@ -352,7 +347,7 @@ export const dbMetaEpic = (some$, store) =>
store.dispatch(updateMeta([]))
return Rx.Observable.of(null)
})
),
}),
// Server configuration
Rx.Observable.fromPromise(
bolt.directTransaction(
Expand Down

0 comments on commit d22d3c4

Please sign in to comment.