diff --git a/__inline-deps__/data-plane-gateway-0.0.0-20251201-150928.tgz b/__inline-deps__/data-plane-gateway-0.0.0-20251201-150928.tgz deleted file mode 100644 index f189102423..0000000000 Binary files a/__inline-deps__/data-plane-gateway-0.0.0-20251201-150928.tgz and /dev/null differ diff --git a/__inline-deps__/data-plane-gateway-0.0.0-20260622-190856.tgz b/__inline-deps__/data-plane-gateway-0.0.0-20260622-190856.tgz new file mode 100644 index 0000000000..3407029309 Binary files /dev/null and b/__inline-deps__/data-plane-gateway-0.0.0-20260622-190856.tgz differ diff --git a/package-lock.json b/package-lock.json index 8a2370e4f1..92365ee5c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,7 @@ "@urql/exchange-request-policy": "^2.0.0", "@urql/exchange-retry": "^2.0.0", "ansicolor": "^2.0.1", - "data-plane-gateway": "file:__inline-deps__/data-plane-gateway-0.0.0-20251201-150928.tgz", + "data-plane-gateway": "file:__inline-deps__/data-plane-gateway-0.0.0-20260622-190856.tgz", "date-fns": "^4.1.0", "dayjs": "^1.11.19", "echarts": "^5.4.3", @@ -8518,8 +8518,8 @@ }, "node_modules/data-plane-gateway": { "version": "0.0.0", - "resolved": "file:__inline-deps__/data-plane-gateway-0.0.0-20251201-150928.tgz", - "integrity": "sha512-Jj2jgjMcs2XgcAVzlGLQvLOVafDaJHvJMpUK8YR3rRywZdurnP0lV8W75U6vzM0DrB88JkqstCCy8176+nkmRA==", + "resolved": "file:__inline-deps__/data-plane-gateway-0.0.0-20260622-190856.tgz", + "integrity": "sha512-wO9ewszbaYcjyHZkxoXAqOE48nzBBNJP5ZRjtd3vcSoZCd0ZC26d+5xEfrL/TO0/Ss1fKznxJVD/g5tHFKrgPg==", "license": "MIT" }, "node_modules/data-uri-to-buffer": { diff --git a/package.json b/package.json index d14beb5024..d6e364fc71 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "@urql/exchange-request-policy": "^2.0.0", "@urql/exchange-retry": "^2.0.0", "ansicolor": "^2.0.1", - "data-plane-gateway": "file:__inline-deps__/data-plane-gateway-0.0.0-20251201-150928.tgz", + "data-plane-gateway": "file:__inline-deps__/data-plane-gateway-0.0.0-20260622-190856.tgz", "date-fns": "^4.1.0", "dayjs": "^1.11.19", "echarts": "^5.4.3", diff --git a/src/hooks/journals/useJournalData.ts b/src/hooks/journals/useJournalData.ts index 11c0d01411..7b983955b2 100644 --- a/src/hooks/journals/useJournalData.ts +++ b/src/hooks/journals/useJournalData.ts @@ -5,18 +5,15 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useShallow } from 'zustand/react/shallow'; import { JournalClient, JournalSelector } from 'data-plane-gateway'; -import { isEmpty } from 'lodash'; import { useCounter } from 'react-use'; import useSWR from 'swr'; import { singleCallSettings } from 'src/context/SWR'; import { useUserStore } from 'src/context/User/useUserContextStore'; import { loadDocuments } from 'src/hooks/journals/shared'; -import { logRocketEvent } from 'src/services/shared'; +import { FETCH_DEFAULT_ERROR, logRocketEvent } from 'src/services/shared'; import useJournalStore from 'src/stores/JournalData/Store'; import { - getJournals, - isNestedProtocolListResponse, MAX_DOCUMENT_SIZE, shouldRefreshToken, } from 'src/utils/dataPlane-utils'; @@ -54,31 +51,30 @@ const useJournalsForCollection = (collectionName: string | undefined) => { brokerAddress && brokerToken ) { - const journalSelector = new JournalSelector().collection( - collectionName - ); + try { + const result = await journalClient.list( + new JournalSelector().collection(collectionName) + ); - const dataPlaneListResponse = await getJournals( - brokerAddress, - brokerToken, - { - include: journalSelector.toLabelSet(), + // Returning the rejected promise (rather than throwing) keeps + // this out of the catch below, so the broker's error message + // reaches SWR's onError for token-refresh handling. + if (result.err()) { + return Promise.reject({ + message: + result.unwrap_err().body.message ?? + FETCH_DEFAULT_ERROR, + }); } - ); - if (isEmpty(dataPlaneListResponse)) { - return Promise.reject(dataPlaneListResponse); + return { + journals: result.unwrap().journals ?? [], + }; + } catch { + // The gateway client throws on transport-level failures it + // cannot parse into a ResponseError, e.g. a network error. + return Promise.reject({ message: FETCH_DEFAULT_ERROR }); } - - const journals = isNestedProtocolListResponse( - dataPlaneListResponse - ) - ? dataPlaneListResponse.result.journals - : dataPlaneListResponse.journals; - - return { - journals: journals ?? [], - }; } else { return null; } diff --git a/src/utils/dataPlane-utils.ts b/src/utils/dataPlane-utils.ts index a86d25a621..b316390ced 100644 --- a/src/utils/dataPlane-utils.ts +++ b/src/utils/dataPlane-utils.ts @@ -1,8 +1,4 @@ import type { Session } from '@supabase/supabase-js'; -import type { - ProtocolLabelSelector, - ProtocolListResponse, -} from 'data-plane-gateway/types/gen/broker/protocol/broker'; import type { Shard } from 'data-plane-gateway/types/shard_client'; import type { ResponseError } from 'data-plane-gateway/types/util'; import type { BaseDataPlaneQuery } from 'src/api/dataPlanes'; @@ -188,23 +184,6 @@ export const authorizeCollection = async ( accessToken ); -// Streaming RPC responses going through grpc-gateway have a `result` vs `error` top-level property added, -// which wraps the actual response. The old data-plane gateway returns unary RPC responses from the /list APIs, -// which don't have a top-level `result` property. -export const isNestedProtocolListResponse = ( - response: { result: ProtocolListResponse } | ProtocolListResponse -): response is { result: ProtocolListResponse } => 'result' in response; - -export const getJournals = async ( - brokerAddress: string, - brokerToken: string, - selector: ProtocolLabelSelector -): Promise<{ result: ProtocolListResponse } | ProtocolListResponse> => - client( - `${brokerAddress}/v1/journals/list`, - { data: { selector } }, - brokerToken - ); /** @deprecated Scope is returned by dataplane gql query */ export const getDataPlaneScope = ( dataPlaneName: string