From d22d3c43af20b56066dace092e5ea7ae4ce8cae6 Mon Sep 17 00:00:00 2001 From: Oskar Hane Date: Mon, 4 May 2020 12:11:23 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20Don=E2=80=99t=20run=20meta=20query=20on?= =?UTF-8?q?=20system=20db?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/shared/modules/dbMeta/dbMetaDuck.js | 51 +++++++++++-------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/shared/modules/dbMeta/dbMetaDuck.js b/src/shared/modules/dbMeta/dbMetaDuck.js index 8beec268c08..6d13eba4f19 100644 --- a/src/shared/modules/dbMeta/dbMetaDuck.js +++ b/src/shared/modules/dbMeta/dbMetaDuck.js @@ -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) { @@ -352,7 +347,7 @@ export const dbMetaEpic = (some$, store) => store.dispatch(updateMeta([])) return Rx.Observable.of(null) }) - ), + }), // Server configuration Rx.Observable.fromPromise( bolt.directTransaction(