From 8fd34124733229bdd1572e46c8be3771d1337df3 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Fri, 31 Jul 2026 16:29:33 +0200 Subject: [PATCH 01/10] Add the update-ID range to reconnect request spans and alert on the older loop-breaker A repeated GetMissingOnyxMessages call is only readable with the range it asked for: a range that advances is a client catching up on a busy account, a range that repeats is a client stuck in a loop. The span carried neither, so classifying the two shapes meant inferring from response sizes. Stamp updateIDFrom/updateIDTo onto the outgoing request span via Sentry's beforeOutgoingRequestSpan hook. It reads the values out of the request body, so it lands on the same http.client span that existing Sentry queries match, which no middleware or call-site span can reach. Only GetMissingOnyxMessages and incremental ReconnectApp send those fields, so nothing else is stamped. Also switch the older loop-breaker in validateAndApplyDeferredUpdates from Log.info to Log.alert. Info stays on the device, so we could not tell whether that guard has ever fired in the field, while the newer guard in OnyxUpdateManager already alerts and is countable. No change to reconnect or gap-detection behaviour. Co-Authored-By: Claude Opus 5 (1M context) --- src/CONST/index.ts | 2 + .../actions/OnyxUpdateManager/utils/index.ts | 4 +- src/libs/telemetry/stampUpdateIDRange.ts | 35 ++++++++++++++ src/setup/telemetry/setupSentry.ts | 3 ++ tests/unit/stampUpdateIDRangeTest.ts | 46 +++++++++++++++++++ 5 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 src/libs/telemetry/stampUpdateIDRange.ts create mode 100644 tests/unit/stampUpdateIDRangeTest.ts diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 24e2033b9a99..a58fd3d8118b 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -2259,6 +2259,8 @@ const CONST = { ATTRIBUTE_FAST_PATH_HANDLER: 'fast_path_handler', ATTRIBUTE_COMMAND: 'command', ATTRIBUTE_JSON_CODE: 'json_code', + ATTRIBUTE_UPDATE_ID_FROM: 'update_id_from', + ATTRIBUTE_UPDATE_ID_TO: 'update_id_to', ATTRIBUTE_COLD_START: 'cold_start', ATTRIBUTE_TRIGGER: 'trigger', ATTRIBUTE_PLATFORM: 'platform', diff --git a/src/libs/actions/OnyxUpdateManager/utils/index.ts b/src/libs/actions/OnyxUpdateManager/utils/index.ts index 115d177cec89..41b1555e662c 100644 --- a/src/libs/actions/OnyxUpdateManager/utils/index.ts +++ b/src/libs/actions/OnyxUpdateManager/utils/index.ts @@ -158,9 +158,9 @@ function validateAndApplyDeferredUpdates(clientLastUpdateID?: number, previousPa return; } - // Prevent info loops of calls to GetMissingOnyxMessages + // Prevent info loops of calls to GetMissingOnyxMessages. Alert, not info: this is the only signal the loop happened. if (previousParams?.newLastUpdateIDFromClient === newLastUpdateIDFromClient && previousParams?.latestMissingUpdateID === latestMissingUpdateID) { - Log.info('[DeferredUpdates] Aborting call to GetMissingOnyxMessages, repeated params', false, {lastUpdateIDFromClient, latestMissingUpdateID, previousParams}); + Log.alert('[DeferredUpdates] Aborting call to GetMissingOnyxMessages, repeated params', {lastUpdateIDFromClient, latestMissingUpdateID, previousParams}); resolve(undefined); return; } diff --git a/src/libs/telemetry/stampUpdateIDRange.ts b/src/libs/telemetry/stampUpdateIDRange.ts new file mode 100644 index 000000000000..c06dabcd5f30 --- /dev/null +++ b/src/libs/telemetry/stampUpdateIDRange.ts @@ -0,0 +1,35 @@ +import CONST from '@src/CONST'; + +import type {FetchBreadcrumbHint, Span, XhrBreadcrumbHint} from '@sentry/core'; + +function getNumericFormField(body: FormData, key: string): number | undefined { + const value = Number(body.getAll(key).at(0)); + return Number.isFinite(value) ? value : undefined; +} + +/** + * Sentry's `beforeOutgoingRequestSpan` hook, whose hint holds the arguments the request was made with. A repeated + * fetch only means something with its range attached: a range that advances is a client catching up, a range that + * repeats is a client stuck in a loop. + */ +function stampUpdateIDRange(span: Pick, hint: FetchBreadcrumbHint | XhrBreadcrumbHint): void { + const requestInit: unknown = Array.isArray(hint.input) ? hint.input.at(1) : undefined; + const body = requestInit && typeof requestInit === 'object' && 'body' in requestInit ? requestInit.body : undefined; + + if (!(body instanceof FormData)) { + return; + } + + const updateIDFrom = getNumericFormField(body, 'updateIDFrom'); + + if (updateIDFrom === undefined) { + return; + } + + span.setAttributes({ + [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_FROM]: updateIDFrom, + [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_TO]: getNumericFormField(body, 'updateIDTo'), + }); +} + +export default stampUpdateIDRange; diff --git a/src/setup/telemetry/setupSentry.ts b/src/setup/telemetry/setupSentry.ts index 40a1ec988412..b993c3cdcaac 100644 --- a/src/setup/telemetry/setupSentry.ts +++ b/src/setup/telemetry/setupSentry.ts @@ -1,6 +1,7 @@ import {isDevelopment} from '@libs/Environment/Environment'; import {breadcrumbsIntegration, browserProfilingIntegration, consoleIntegration, navigationIntegration, reportingObserverIntegration, tracingIntegration} from '@libs/telemetry/integrations'; import {processBeforeSendLogs, processBeforeSendTransactions} from '@libs/telemetry/middlewares'; +import stampUpdateIDRange from '@libs/telemetry/stampUpdateIDRange'; import CONFIG from '@src/CONFIG'; import CONST from '@src/CONST'; @@ -49,6 +50,8 @@ function setupSentry(): void { }, }); + Sentry.getClient()?.on('beforeOutgoingRequestSpan', stampUpdateIDRange); + Sentry.setTag(CONST.TELEMETRY.TAGS.BUILD_TYPE, CONFIG.IS_HYBRID_APP ? CONST.TELEMETRY.BUILD_TYPE_HYBRID_APP : CONST.TELEMETRY.BUILD_TYPE_STANDALONE); } diff --git a/tests/unit/stampUpdateIDRangeTest.ts b/tests/unit/stampUpdateIDRangeTest.ts new file mode 100644 index 000000000000..06879431f729 --- /dev/null +++ b/tests/unit/stampUpdateIDRangeTest.ts @@ -0,0 +1,46 @@ +import stampUpdateIDRange from '@libs/telemetry/stampUpdateIDRange'; + +import CONST from '@src/CONST'; + +const setAttributes = jest.fn(); +const span = {setAttributes}; + +const requestWith = (fields: Record) => { + const body = new FormData(); + for (const [key, value] of Object.entries(fields)) { + body.append(key, value); + } + return {input: ['https://www.expensify.com/api/GetMissingOnyxMessages', {method: 'post', body}], startTimestamp: 0}; +}; + +describe('stampUpdateIDRange', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('stamps the range of a GetMissingOnyxMessages request as numbers', () => { + stampUpdateIDRange(span, requestWith({updateIDFrom: '100', updateIDTo: '200'})); + + expect(setAttributes).toHaveBeenCalledWith({ + [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_FROM]: 100, + [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_TO]: 200, + }); + }); + + it('stamps only the start of an incremental ReconnectApp request, which has no end', () => { + stampUpdateIDRange(span, requestWith({updateIDFrom: '100', policyIDList: ''})); + + expect(setAttributes).toHaveBeenCalledWith({ + [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_FROM]: 100, + [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_TO]: undefined, + }); + }); + + it('leaves requests without an update-ID range alone', () => { + stampUpdateIDRange(span, requestWith({reportID: '1234'})); + stampUpdateIDRange(span, {input: ['https://www.expensify.com/api/OpenApp', {method: 'post'}], startTimestamp: 0}); + stampUpdateIDRange(span, {input: [], startTimestamp: 0}); + + expect(setAttributes).not.toHaveBeenCalled(); + }); +}); From a05056fa5fc6fe76dfe37d0c709e8747ca77d368 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Fri, 31 Jul 2026 16:34:09 +0200 Subject: [PATCH 02/10] Simplify the telemetry comments to plain technical English Co-Authored-By: Claude Opus 5 (1M context) --- src/libs/actions/OnyxUpdateManager/utils/index.ts | 2 +- src/libs/telemetry/stampUpdateIDRange.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/OnyxUpdateManager/utils/index.ts b/src/libs/actions/OnyxUpdateManager/utils/index.ts index 41b1555e662c..c7b639f0eed5 100644 --- a/src/libs/actions/OnyxUpdateManager/utils/index.ts +++ b/src/libs/actions/OnyxUpdateManager/utils/index.ts @@ -158,7 +158,7 @@ function validateAndApplyDeferredUpdates(clientLastUpdateID?: number, previousPa return; } - // Prevent info loops of calls to GetMissingOnyxMessages. Alert, not info: this is the only signal the loop happened. + // Prevent info loops of calls to GetMissingOnyxMessages if (previousParams?.newLastUpdateIDFromClient === newLastUpdateIDFromClient && previousParams?.latestMissingUpdateID === latestMissingUpdateID) { Log.alert('[DeferredUpdates] Aborting call to GetMissingOnyxMessages, repeated params', {lastUpdateIDFromClient, latestMissingUpdateID, previousParams}); resolve(undefined); diff --git a/src/libs/telemetry/stampUpdateIDRange.ts b/src/libs/telemetry/stampUpdateIDRange.ts index c06dabcd5f30..5f30e36c3311 100644 --- a/src/libs/telemetry/stampUpdateIDRange.ts +++ b/src/libs/telemetry/stampUpdateIDRange.ts @@ -8,9 +8,9 @@ function getNumericFormField(body: FormData, key: string): number | undefined { } /** - * Sentry's `beforeOutgoingRequestSpan` hook, whose hint holds the arguments the request was made with. A repeated - * fetch only means something with its range attached: a range that advances is a client catching up, a range that - * repeats is a client stuck in a loop. + * Runs on Sentry's `beforeOutgoingRequestSpan` hook. The hook hint holds the request arguments, so this function reads + * the update-ID range from the `FormData` body and stamps the range on the auto-instrumented `http.client` span. + * A range that advances means the client is catching up. A range that repeats means the client is stuck in a loop. */ function stampUpdateIDRange(span: Pick, hint: FetchBreadcrumbHint | XhrBreadcrumbHint): void { const requestInit: unknown = Array.isArray(hint.input) ? hint.input.at(1) : undefined; From dc69daa7a256317963e06bd2529365010c344a36 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Wed, 5 Aug 2026 18:23:25 +0200 Subject: [PATCH 03/10] Move the reconnect telemetry onto the middleware that sees the response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Sentry `beforeOutgoingRequestSpan` approach could not work on native. It reads the request body out of `hint.input`, and only the fetch path populates that field. React Native's tracing integration sets `traceFetch: false` and `traceXHR: true`, so on iOS and Android the hook fired with no body to read and stamped nothing — on exactly the platforms where reconnect storms hurt most. The hook also fires at request start, so it can never answer the question the telemetry exists for: did this call advance the client. That is a comparison against the response. Sentry search compares a field to a literal, not to another field, so `last_update_id <= update_id_from` is not expressible as a query either. The verdict has to be computed at write time and stored. `SentryServerTiming` already runs for every command, already sees both the request and the response, and its own comment says to extend `TRACKED_COMMAND_GROUPS` rather than add a middleware. Reconnect commands get a group there, with `update_id_from` from the request and `response_advanced` from the response. Two details worth naming: `update_id_from` is absent on a full ReconnectApp, which refetches everything, so `response_advanced` is left off those spans too — there is nothing to advance past. That also keeps the attribute off the write-command spans in the other group. The check is `=== undefined` rather than truthiness because `updateIDFrom` is legitimately 0 for GetMissingOnyxMessages. Span ids no longer key off `requestIndex`. That field is only set on persisted write requests, so every reconnect span shared one key, and starting the next span cancelled the one still in flight — a collision in precisely the overlapping-burst case this measures. Co-Authored-By: Claude Opus 5 (1M context) --- src/CONST/index.ts | 5 +- src/libs/Middleware/SentryServerTiming.ts | 34 +++++++++- src/libs/telemetry/stampUpdateIDRange.ts | 35 ----------- src/setup/telemetry/setupSentry.ts | 3 - .../unit/SentryServerTimingMiddlewareTest.ts | 62 +++++++++++++++++++ tests/unit/stampUpdateIDRangeTest.ts | 46 -------------- 6 files changed, 98 insertions(+), 87 deletions(-) delete mode 100644 src/libs/telemetry/stampUpdateIDRange.ts create mode 100644 tests/unit/SentryServerTimingMiddlewareTest.ts delete mode 100644 tests/unit/stampUpdateIDRangeTest.ts diff --git a/src/CONST/index.ts b/src/CONST/index.ts index a58fd3d8118b..a18c8868d743 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -2186,6 +2186,7 @@ const CONST = { SPAN_SUBMIT_EXPENSE: 'ManualCreateExpenseSubmit', SPAN_SUBMIT_TO_DESTINATION_VISIBLE: 'ManualSubmitToDestinationVisible', SPAN_EXPENSE_SERVER_RESPONSE: 'ManualCreateExpenseServerResponse', + SPAN_RECONNECT_SERVER_RESPONSE: 'ManualReconnectServerResponse', SPAN_GEOLOCATION_WAIT: 'ManualGeolocationWait', SPAN_SEND_MESSAGE: 'ManualSendMessage', SPAN_NOT_FOUND_PAGE: 'ManualNotFoundPage', @@ -2259,8 +2260,10 @@ const CONST = { ATTRIBUTE_FAST_PATH_HANDLER: 'fast_path_handler', ATTRIBUTE_COMMAND: 'command', ATTRIBUTE_JSON_CODE: 'json_code', + /** The update ID a reconnect request asked to catch up from. Absent on a full ReconnectApp, which refetches everything. */ ATTRIBUTE_UPDATE_ID_FROM: 'update_id_from', - ATTRIBUTE_UPDATE_ID_TO: 'update_id_to', + /** Whether a reconnect response carried a newer update ceiling than the request asked from. False is the stall loop. */ + ATTRIBUTE_RESPONSE_ADVANCED: 'response_advanced', ATTRIBUTE_COLD_START: 'cold_start', ATTRIBUTE_TRIGGER: 'trigger', ATTRIBUTE_PLATFORM: 'platform', diff --git a/src/libs/Middleware/SentryServerTiming.ts b/src/libs/Middleware/SentryServerTiming.ts index 0f1940dbe228..1049ac369c15 100644 --- a/src/libs/Middleware/SentryServerTiming.ts +++ b/src/libs/Middleware/SentryServerTiming.ts @@ -1,4 +1,5 @@ -import {WRITE_COMMANDS} from '@libs/API/types'; +import {readUpdateIDFrom} from '@libs/actions/RequestConflictUtils'; +import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import {cancelSpan, endSpanWithAttributes, startSpan} from '@libs/telemetry/activeSpans'; import CONST from '@src/CONST'; @@ -39,6 +40,11 @@ const TRACKED_COMMAND_GROUPS: TrackedCommandGroup[] = [ spanOp: CONST.TELEMETRY.SPAN_EXPENSE_SERVER_RESPONSE, spanName: 'expense-server-response', }, + { + commands: new Set([SIDE_EFFECT_REQUEST_COMMANDS.RECONNECT_APP, SIDE_EFFECT_REQUEST_COMMANDS.GET_MISSING_ONYX_MESSAGES]), + spanOp: CONST.TELEMETRY.SPAN_RECONNECT_SERVER_RESPONSE, + spanName: 'reconnect-server-response', + }, ]; /** @@ -48,6 +54,26 @@ function findTrackedGroup(command: string): TrackedCommandGroup | undefined { return TRACKED_COMMAND_GROUPS.find((group) => group.commands.has(command)); } +/** + * Distinguishes the spans of overlapping requests. `requestIndex` only exists on persisted write requests, so + * side-effect commands like GetMissingOnyxMessages would otherwise all share one span id, and starting the next + * span would cancel the one still in flight. + */ +let spanSequence = 0; + +/** + * Whether a reconnect response carried a newer update ceiling than the request asked to catch up from. + * A request with no `updateIDFrom` refetches everything, so there is nothing to advance past and the + * answer is left off the span. Sentry cannot compare one attribute against another, so this verdict has + * to be computed here rather than left to a query. + */ +function didResponseAdvance(updateIDFrom: number | undefined, lastUpdateID: number | string | undefined): boolean | undefined { + if (updateIDFrom === undefined) { + return undefined; + } + return Number(lastUpdateID ?? CONST.DEFAULT_NUMBER_ID) > updateIDFrom; +} + /** * Middleware that tracks server round-trip time for configured command groups via Sentry spans. * For non-tracked commands, this is a no-op pass-through. @@ -60,12 +86,15 @@ const SentryServerTiming: Middleware = (response, request) => { return response; } - const spanId = `${group.spanOp}_${request.requestIndex}`; + const updateIDFrom = readUpdateIDFrom(request.data); + spanSequence += 1; + const spanId = `${group.spanOp}_${spanSequence}`; startSpan(spanId, { name: group.spanName, op: group.spanOp, attributes: { [CONST.TELEMETRY.ATTRIBUTE_COMMAND]: request.command, + [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_FROM]: updateIDFrom, }, }); @@ -73,6 +102,7 @@ const SentryServerTiming: Middleware = (response, request) => { .then((data) => { const attributes: SpanAttributes = { [CONST.TELEMETRY.ATTRIBUTE_JSON_CODE]: data?.jsonCode, + [CONST.TELEMETRY.ATTRIBUTE_RESPONSE_ADVANCED]: didResponseAdvance(updateIDFrom, data?.lastUpdateID), }; endSpanWithAttributes(spanId, attributes); return data; diff --git a/src/libs/telemetry/stampUpdateIDRange.ts b/src/libs/telemetry/stampUpdateIDRange.ts deleted file mode 100644 index 5f30e36c3311..000000000000 --- a/src/libs/telemetry/stampUpdateIDRange.ts +++ /dev/null @@ -1,35 +0,0 @@ -import CONST from '@src/CONST'; - -import type {FetchBreadcrumbHint, Span, XhrBreadcrumbHint} from '@sentry/core'; - -function getNumericFormField(body: FormData, key: string): number | undefined { - const value = Number(body.getAll(key).at(0)); - return Number.isFinite(value) ? value : undefined; -} - -/** - * Runs on Sentry's `beforeOutgoingRequestSpan` hook. The hook hint holds the request arguments, so this function reads - * the update-ID range from the `FormData` body and stamps the range on the auto-instrumented `http.client` span. - * A range that advances means the client is catching up. A range that repeats means the client is stuck in a loop. - */ -function stampUpdateIDRange(span: Pick, hint: FetchBreadcrumbHint | XhrBreadcrumbHint): void { - const requestInit: unknown = Array.isArray(hint.input) ? hint.input.at(1) : undefined; - const body = requestInit && typeof requestInit === 'object' && 'body' in requestInit ? requestInit.body : undefined; - - if (!(body instanceof FormData)) { - return; - } - - const updateIDFrom = getNumericFormField(body, 'updateIDFrom'); - - if (updateIDFrom === undefined) { - return; - } - - span.setAttributes({ - [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_FROM]: updateIDFrom, - [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_TO]: getNumericFormField(body, 'updateIDTo'), - }); -} - -export default stampUpdateIDRange; diff --git a/src/setup/telemetry/setupSentry.ts b/src/setup/telemetry/setupSentry.ts index b993c3cdcaac..40a1ec988412 100644 --- a/src/setup/telemetry/setupSentry.ts +++ b/src/setup/telemetry/setupSentry.ts @@ -1,7 +1,6 @@ import {isDevelopment} from '@libs/Environment/Environment'; import {breadcrumbsIntegration, browserProfilingIntegration, consoleIntegration, navigationIntegration, reportingObserverIntegration, tracingIntegration} from '@libs/telemetry/integrations'; import {processBeforeSendLogs, processBeforeSendTransactions} from '@libs/telemetry/middlewares'; -import stampUpdateIDRange from '@libs/telemetry/stampUpdateIDRange'; import CONFIG from '@src/CONFIG'; import CONST from '@src/CONST'; @@ -50,8 +49,6 @@ function setupSentry(): void { }, }); - Sentry.getClient()?.on('beforeOutgoingRequestSpan', stampUpdateIDRange); - Sentry.setTag(CONST.TELEMETRY.TAGS.BUILD_TYPE, CONFIG.IS_HYBRID_APP ? CONST.TELEMETRY.BUILD_TYPE_HYBRID_APP : CONST.TELEMETRY.BUILD_TYPE_STANDALONE); } diff --git a/tests/unit/SentryServerTimingMiddlewareTest.ts b/tests/unit/SentryServerTimingMiddlewareTest.ts new file mode 100644 index 000000000000..3460b503ef8f --- /dev/null +++ b/tests/unit/SentryServerTimingMiddlewareTest.ts @@ -0,0 +1,62 @@ +import SentryServerTiming from '@libs/Middleware/SentryServerTiming'; +import {endSpanWithAttributes, startSpan} from '@libs/telemetry/activeSpans'; + +import CONST from '@src/CONST'; +import type Request from '@src/types/onyx/Request'; +import type Response from '@src/types/onyx/Response'; + +import type {OnyxKey} from 'react-native-onyx'; + +jest.mock('@libs/telemetry/activeSpans', () => ({ + startSpan: jest.fn(), + endSpanWithAttributes: jest.fn(), + cancelSpan: jest.fn(), +})); + +function buildRequest(command: string, data: Record): Request { + return {command, data}; +} + +function buildResponse(lastUpdateID: number): Response { + return {jsonCode: 200, lastUpdateID}; +} + +describe('SentryServerTiming middleware', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('marks a GetMissingOnyxMessages response as not advanced when its ceiling matches what the request asked from', async () => { + const request = buildRequest('GetMissingOnyxMessages', {updateIDFrom: 8102, updateIDTo: 8102}); + + await SentryServerTiming(Promise.resolve(buildResponse(8102)), request, false); + + expect(endSpanWithAttributes).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({[CONST.TELEMETRY.ATTRIBUTE_RESPONSE_ADVANCED]: false})); + }); + + it('marks a GetMissingOnyxMessages response as advanced when its ceiling is newer', async () => { + const request = buildRequest('GetMissingOnyxMessages', {updateIDFrom: 8102, updateIDTo: 8200}); + + await SentryServerTiming(Promise.resolve(buildResponse(8200)), request, false); + + expect(endSpanWithAttributes).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({[CONST.TELEMETRY.ATTRIBUTE_RESPONSE_ADVANCED]: true})); + }); + + it('leaves the verdict off a full ReconnectApp, which refetches everything and has nothing to advance past', async () => { + const request = buildRequest('ReconnectApp', {}); + + await SentryServerTiming(Promise.resolve(buildResponse(8200)), request, false); + + expect(endSpanWithAttributes).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({[CONST.TELEMETRY.ATTRIBUTE_RESPONSE_ADVANCED]: undefined})); + }); + + it('gives overlapping reconnect requests their own span, so one does not cancel the other', async () => { + const first = SentryServerTiming(Promise.resolve(buildResponse(8102)), buildRequest('GetMissingOnyxMessages', {updateIDFrom: 8102}), false); + const second = SentryServerTiming(Promise.resolve(buildResponse(8200)), buildRequest('ReconnectApp', {updateIDFrom: 8102}), false); + + await Promise.all([first, second]); + + const spanIDs = jest.mocked(startSpan).mock.calls.map(([spanID]) => spanID); + expect(new Set(spanIDs).size).toBe(2); + }); +}); diff --git a/tests/unit/stampUpdateIDRangeTest.ts b/tests/unit/stampUpdateIDRangeTest.ts deleted file mode 100644 index 06879431f729..000000000000 --- a/tests/unit/stampUpdateIDRangeTest.ts +++ /dev/null @@ -1,46 +0,0 @@ -import stampUpdateIDRange from '@libs/telemetry/stampUpdateIDRange'; - -import CONST from '@src/CONST'; - -const setAttributes = jest.fn(); -const span = {setAttributes}; - -const requestWith = (fields: Record) => { - const body = new FormData(); - for (const [key, value] of Object.entries(fields)) { - body.append(key, value); - } - return {input: ['https://www.expensify.com/api/GetMissingOnyxMessages', {method: 'post', body}], startTimestamp: 0}; -}; - -describe('stampUpdateIDRange', () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - - it('stamps the range of a GetMissingOnyxMessages request as numbers', () => { - stampUpdateIDRange(span, requestWith({updateIDFrom: '100', updateIDTo: '200'})); - - expect(setAttributes).toHaveBeenCalledWith({ - [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_FROM]: 100, - [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_TO]: 200, - }); - }); - - it('stamps only the start of an incremental ReconnectApp request, which has no end', () => { - stampUpdateIDRange(span, requestWith({updateIDFrom: '100', policyIDList: ''})); - - expect(setAttributes).toHaveBeenCalledWith({ - [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_FROM]: 100, - [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_TO]: undefined, - }); - }); - - it('leaves requests without an update-ID range alone', () => { - stampUpdateIDRange(span, requestWith({reportID: '1234'})); - stampUpdateIDRange(span, {input: ['https://www.expensify.com/api/OpenApp', {method: 'post'}], startTimestamp: 0}); - stampUpdateIDRange(span, {input: [], startTimestamp: 0}); - - expect(setAttributes).not.toHaveBeenCalled(); - }); -}); From 1f7a2f425ec5d29dea3292a4ac3351fe1e8882c3 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Wed, 5 Aug 2026 18:40:50 +0200 Subject: [PATCH 04/10] Stamp update_id_to alongside update_id_from on reconnect spans The floor alone cannot separate two different stalls. When update_id_from holds still and update_id_to keeps rising, the client is falling behind a server that keeps producing updates. When both hold still, the client is stuck asking for a range the server will not serve. `response_advanced` reads false in both cases. The earlier reasoning for dropping this attribute was that Sentry cannot subtract two attributes, so it cannot report backlog size. True, but the useful query needs no subtraction: group by user.id, then plot count_unique(update_id_from) against count_unique(update_id_to). A unique floor of 1 against a rising target is the falling-behind case. The value is real on every GetMissingOnyxMessages call, never the 0 default: it arrives as lastUpdateIDFromServer, previousUpdateIDFromServer, or latestMissingUpdateID. ReconnectApp has no target, so the attribute stays off those spans. Co-Authored-By: Claude Opus 5 (1M context) --- src/CONST/index.ts | 6 +++++ src/libs/Middleware/SentryServerTiming.ts | 12 ++++++++++ .../unit/SentryServerTimingMiddlewareTest.ts | 24 +++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index a18c8868d743..de7b41a29b7a 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -2262,6 +2262,12 @@ const CONST = { ATTRIBUTE_JSON_CODE: 'json_code', /** The update ID a reconnect request asked to catch up from. Absent on a full ReconnectApp, which refetches everything. */ ATTRIBUTE_UPDATE_ID_FROM: 'update_id_from', + /** + * The update ID a GetMissingOnyxMessages request asked to catch up to. Pairs with `update_id_from` to separate a + * client that falls behind a busy server, where this keeps rising, from a client stuck on a range the server + * will not serve, where both hold still. ReconnectApp has no such target. + */ + ATTRIBUTE_UPDATE_ID_TO: 'update_id_to', /** Whether a reconnect response carried a newer update ceiling than the request asked from. False is the stall loop. */ ATTRIBUTE_RESPONSE_ADVANCED: 'response_advanced', ATTRIBUTE_COLD_START: 'cold_start', diff --git a/src/libs/Middleware/SentryServerTiming.ts b/src/libs/Middleware/SentryServerTiming.ts index 1049ac369c15..9b0f53b9e16a 100644 --- a/src/libs/Middleware/SentryServerTiming.ts +++ b/src/libs/Middleware/SentryServerTiming.ts @@ -3,8 +3,10 @@ import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import {cancelSpan, endSpanWithAttributes, startSpan} from '@libs/telemetry/activeSpans'; import CONST from '@src/CONST'; +import type Request from '@src/types/onyx/Request'; import type {SpanAttributes} from '@sentry/core'; +import type {OnyxKey} from 'react-native-onyx'; import type Middleware from './types'; @@ -61,6 +63,15 @@ function findTrackedGroup(command: string): TrackedCommandGroup | undefined { */ let spanSequence = 0; +/** + * The update ID a request asked to catch up to. `getMissingOnyxUpdates` types this as `number | string`, so a + * string that does not parse is dropped rather than stamped as NaN. + */ +function readUpdateIDTo(data: Request['data']): number | undefined { + const updateIDTo = Number(data?.updateIDTo); + return Number.isFinite(updateIDTo) ? updateIDTo : undefined; +} + /** * Whether a reconnect response carried a newer update ceiling than the request asked to catch up from. * A request with no `updateIDFrom` refetches everything, so there is nothing to advance past and the @@ -95,6 +106,7 @@ const SentryServerTiming: Middleware = (response, request) => { attributes: { [CONST.TELEMETRY.ATTRIBUTE_COMMAND]: request.command, [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_FROM]: updateIDFrom, + [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_TO]: readUpdateIDTo(request.data), }, }); diff --git a/tests/unit/SentryServerTimingMiddlewareTest.ts b/tests/unit/SentryServerTimingMiddlewareTest.ts index 3460b503ef8f..fab9921d9e92 100644 --- a/tests/unit/SentryServerTimingMiddlewareTest.ts +++ b/tests/unit/SentryServerTimingMiddlewareTest.ts @@ -50,6 +50,30 @@ describe('SentryServerTiming middleware', () => { expect(endSpanWithAttributes).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({[CONST.TELEMETRY.ATTRIBUTE_RESPONSE_ADVANCED]: undefined})); }); + it('stamps the range a GetMissingOnyxMessages request asked for, parsing the string form of the target', async () => { + const request = buildRequest('GetMissingOnyxMessages', {updateIDFrom: 8102, updateIDTo: '8200'}); + + await SentryServerTiming(Promise.resolve(buildResponse(8200)), request, false); + + expect(startSpan).toHaveBeenCalledWith( + expect.any(String), + expect.objectContaining({ + attributes: expect.objectContaining({ + [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_FROM]: 8102, + [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_TO]: 8200, + }), + }), + ); + }); + + it('leaves the target off a ReconnectApp, which has no update ID to catch up to', async () => { + const request = buildRequest('ReconnectApp', {updateIDFrom: 8102}); + + await SentryServerTiming(Promise.resolve(buildResponse(8200)), request, false); + + expect(startSpan).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({attributes: expect.objectContaining({[CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_TO]: undefined})})); + }); + it('gives overlapping reconnect requests their own span, so one does not cancel the other', async () => { const first = SentryServerTiming(Promise.resolve(buildResponse(8102)), buildRequest('GetMissingOnyxMessages', {updateIDFrom: 8102}), false); const second = SentryServerTiming(Promise.resolve(buildResponse(8200)), buildRequest('ReconnectApp', {updateIDFrom: 8102}), false); From f4926f13998507dfa19baccc5fac8d3d196cd3fb Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Wed, 5 Aug 2026 18:52:02 +0200 Subject: [PATCH 05/10] Drop the comments that only restate the code Co-Authored-By: Claude Opus 5 (1M context) --- src/CONST/index.ts | 7 ------- src/libs/Middleware/SentryServerTiming.ts | 20 +++++--------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index de7b41a29b7a..6007287fbb3a 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -2260,15 +2260,8 @@ const CONST = { ATTRIBUTE_FAST_PATH_HANDLER: 'fast_path_handler', ATTRIBUTE_COMMAND: 'command', ATTRIBUTE_JSON_CODE: 'json_code', - /** The update ID a reconnect request asked to catch up from. Absent on a full ReconnectApp, which refetches everything. */ ATTRIBUTE_UPDATE_ID_FROM: 'update_id_from', - /** - * The update ID a GetMissingOnyxMessages request asked to catch up to. Pairs with `update_id_from` to separate a - * client that falls behind a busy server, where this keeps rising, from a client stuck on a range the server - * will not serve, where both hold still. ReconnectApp has no such target. - */ ATTRIBUTE_UPDATE_ID_TO: 'update_id_to', - /** Whether a reconnect response carried a newer update ceiling than the request asked from. False is the stall loop. */ ATTRIBUTE_RESPONSE_ADVANCED: 'response_advanced', ATTRIBUTE_COLD_START: 'cold_start', ATTRIBUTE_TRIGGER: 'trigger', diff --git a/src/libs/Middleware/SentryServerTiming.ts b/src/libs/Middleware/SentryServerTiming.ts index 9b0f53b9e16a..fa36971be969 100644 --- a/src/libs/Middleware/SentryServerTiming.ts +++ b/src/libs/Middleware/SentryServerTiming.ts @@ -56,28 +56,18 @@ function findTrackedGroup(command: string): TrackedCommandGroup | undefined { return TRACKED_COMMAND_GROUPS.find((group) => group.commands.has(command)); } -/** - * Distinguishes the spans of overlapping requests. `requestIndex` only exists on persisted write requests, so - * side-effect commands like GetMissingOnyxMessages would otherwise all share one span id, and starting the next - * span would cancel the one still in flight. - */ +// `requestIndex` only exists on persisted write requests, so side-effect commands would otherwise share one +// span id, and starting the next span cancels the one still in flight. let spanSequence = 0; -/** - * The update ID a request asked to catch up to. `getMissingOnyxUpdates` types this as `number | string`, so a - * string that does not parse is dropped rather than stamped as NaN. - */ +// `getMissingOnyxUpdates` types its target as `number | string`. function readUpdateIDTo(data: Request['data']): number | undefined { const updateIDTo = Number(data?.updateIDTo); return Number.isFinite(updateIDTo) ? updateIDTo : undefined; } -/** - * Whether a reconnect response carried a newer update ceiling than the request asked to catch up from. - * A request with no `updateIDFrom` refetches everything, so there is nothing to advance past and the - * answer is left off the span. Sentry cannot compare one attribute against another, so this verdict has - * to be computed here rather than left to a query. - */ +// Sentry cannot compare one attribute against another, so this verdict has to be computed at write time +// rather than left to a query. function didResponseAdvance(updateIDFrom: number | undefined, lastUpdateID: number | string | undefined): boolean | undefined { if (updateIDFrom === undefined) { return undefined; From a53d60f076eef5ebf7673f9cf52f08f0379a1c30 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Wed, 5 Aug 2026 19:01:20 +0200 Subject: [PATCH 06/10] Trim the remaining comments to the two framework constraints Co-Authored-By: Claude Opus 5 (1M context) --- src/libs/Middleware/SentryServerTiming.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libs/Middleware/SentryServerTiming.ts b/src/libs/Middleware/SentryServerTiming.ts index fa36971be969..ae49524abdcd 100644 --- a/src/libs/Middleware/SentryServerTiming.ts +++ b/src/libs/Middleware/SentryServerTiming.ts @@ -56,18 +56,15 @@ function findTrackedGroup(command: string): TrackedCommandGroup | undefined { return TRACKED_COMMAND_GROUPS.find((group) => group.commands.has(command)); } -// `requestIndex` only exists on persisted write requests, so side-effect commands would otherwise share one -// span id, and starting the next span cancels the one still in flight. +// `requestIndex` is unset on side-effect requests, so keying spans off it collides and cancels one still in flight. let spanSequence = 0; -// `getMissingOnyxUpdates` types its target as `number | string`. function readUpdateIDTo(data: Request['data']): number | undefined { const updateIDTo = Number(data?.updateIDTo); return Number.isFinite(updateIDTo) ? updateIDTo : undefined; } -// Sentry cannot compare one attribute against another, so this verdict has to be computed at write time -// rather than left to a query. +// Sentry cannot compare one attribute against another, so the verdict cannot be left to a query. function didResponseAdvance(updateIDFrom: number | undefined, lastUpdateID: number | string | undefined): boolean | undefined { if (updateIDFrom === undefined) { return undefined; From 62c2a745cb98f6ad4ffc845b51715bffa3a48f5c Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Wed, 5 Aug 2026 19:07:26 +0200 Subject: [PATCH 07/10] Drop spanSequence: requestIndex was already unique per request `prepareRequest` stamps `requestIndex: requestIndex++` on every request it builds (API/index.ts:137), and `makeRequestWithSideEffects` goes through it, so GetMissingOnyxMessages and ReconnectApp already carry a unique monotonic index. The counter added earlier solved nothing. The field reads as optional on the Request type because persisted requests restored from disk can predate it, not because side-effect requests lack it. Also drops the last two comments. Both restated what the code says. Co-Authored-By: Claude Opus 5 (1M context) --- src/libs/Middleware/SentryServerTiming.ts | 7 +------ tests/unit/SentryServerTimingMiddlewareTest.ts | 5 ++++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/libs/Middleware/SentryServerTiming.ts b/src/libs/Middleware/SentryServerTiming.ts index ae49524abdcd..7e4acf79f18a 100644 --- a/src/libs/Middleware/SentryServerTiming.ts +++ b/src/libs/Middleware/SentryServerTiming.ts @@ -56,15 +56,11 @@ function findTrackedGroup(command: string): TrackedCommandGroup | undefined { return TRACKED_COMMAND_GROUPS.find((group) => group.commands.has(command)); } -// `requestIndex` is unset on side-effect requests, so keying spans off it collides and cancels one still in flight. -let spanSequence = 0; - function readUpdateIDTo(data: Request['data']): number | undefined { const updateIDTo = Number(data?.updateIDTo); return Number.isFinite(updateIDTo) ? updateIDTo : undefined; } -// Sentry cannot compare one attribute against another, so the verdict cannot be left to a query. function didResponseAdvance(updateIDFrom: number | undefined, lastUpdateID: number | string | undefined): boolean | undefined { if (updateIDFrom === undefined) { return undefined; @@ -85,8 +81,7 @@ const SentryServerTiming: Middleware = (response, request) => { } const updateIDFrom = readUpdateIDFrom(request.data); - spanSequence += 1; - const spanId = `${group.spanOp}_${spanSequence}`; + const spanId = `${group.spanOp}_${request.requestIndex}`; startSpan(spanId, { name: group.spanName, op: group.spanOp, diff --git a/tests/unit/SentryServerTimingMiddlewareTest.ts b/tests/unit/SentryServerTimingMiddlewareTest.ts index fab9921d9e92..cf3e48b1e9dd 100644 --- a/tests/unit/SentryServerTimingMiddlewareTest.ts +++ b/tests/unit/SentryServerTimingMiddlewareTest.ts @@ -13,8 +13,11 @@ jest.mock('@libs/telemetry/activeSpans', () => ({ cancelSpan: jest.fn(), })); +let requestIndex = 0; + function buildRequest(command: string, data: Record): Request { - return {command, data}; + requestIndex += 1; + return {command, data, requestIndex}; } function buildResponse(lastUpdateID: number): Response { From f583d08d2af458ff5848f8a71bfa94dc7a357c43 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Thu, 6 Aug 2026 12:51:07 +0200 Subject: [PATCH 08/10] Reword the test name so cspell accepts it "refetches" is not in the dictionary; "fetches everything again" says the same thing. Co-Authored-By: Claude Opus 5 (1M context) --- tests/unit/SentryServerTimingMiddlewareTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/SentryServerTimingMiddlewareTest.ts b/tests/unit/SentryServerTimingMiddlewareTest.ts index cf3e48b1e9dd..662b2fe117e8 100644 --- a/tests/unit/SentryServerTimingMiddlewareTest.ts +++ b/tests/unit/SentryServerTimingMiddlewareTest.ts @@ -45,7 +45,7 @@ describe('SentryServerTiming middleware', () => { expect(endSpanWithAttributes).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({[CONST.TELEMETRY.ATTRIBUTE_RESPONSE_ADVANCED]: true})); }); - it('leaves the verdict off a full ReconnectApp, which refetches everything and has nothing to advance past', async () => { + it('leaves the verdict off a full ReconnectApp, which fetches everything again and has nothing to advance past', async () => { const request = buildRequest('ReconnectApp', {}); await SentryServerTiming(Promise.resolve(buildResponse(8200)), request, false); From 4ef1439e8427c486102efe7adff907a2080b0f53 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Thu, 6 Aug 2026 16:38:16 +0200 Subject: [PATCH 09/10] Stop reading a response with no lastUpdateID as a stalled client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit didResponseAdvance defaulted a missing lastUpdateID to 0, so an unreadable answer compared as 0 > updateIDFrom and stamped response_advanced: false — indistinguishable from a client genuinely re-asking for the same range. Return undefined instead, so an absent verdict means "could not tell". The presence of update_id_from still separates that from a full reconnect, which has nothing to compare against in the first place. Co-Authored-By: Claude Opus 5 (1M context) --- src/libs/Middleware/SentryServerTiming.ts | 5 +++-- tests/unit/SentryServerTimingMiddlewareTest.ts | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libs/Middleware/SentryServerTiming.ts b/src/libs/Middleware/SentryServerTiming.ts index 7e4acf79f18a..87204b40c87c 100644 --- a/src/libs/Middleware/SentryServerTiming.ts +++ b/src/libs/Middleware/SentryServerTiming.ts @@ -62,10 +62,11 @@ function readUpdateIDTo(data: Request['data']): number | undefined { } function didResponseAdvance(updateIDFrom: number | undefined, lastUpdateID: number | string | undefined): boolean | undefined { - if (updateIDFrom === undefined) { + const responseUpdateID = Number(lastUpdateID); + if (updateIDFrom === undefined || !Number.isFinite(responseUpdateID)) { return undefined; } - return Number(lastUpdateID ?? CONST.DEFAULT_NUMBER_ID) > updateIDFrom; + return responseUpdateID > updateIDFrom; } /** diff --git a/tests/unit/SentryServerTimingMiddlewareTest.ts b/tests/unit/SentryServerTimingMiddlewareTest.ts index 662b2fe117e8..fb237352b4f0 100644 --- a/tests/unit/SentryServerTimingMiddlewareTest.ts +++ b/tests/unit/SentryServerTimingMiddlewareTest.ts @@ -53,6 +53,14 @@ describe('SentryServerTiming middleware', () => { expect(endSpanWithAttributes).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({[CONST.TELEMETRY.ATTRIBUTE_RESPONSE_ADVANCED]: undefined})); }); + it('leaves the verdict off when the response carries no update ID, so an unreadable answer never reads as a stall', async () => { + const request = buildRequest('ReconnectApp', {updateIDFrom: 8102}); + + await SentryServerTiming(Promise.resolve({jsonCode: 200}), request, false); + + expect(endSpanWithAttributes).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({[CONST.TELEMETRY.ATTRIBUTE_RESPONSE_ADVANCED]: undefined})); + }); + it('stamps the range a GetMissingOnyxMessages request asked for, parsing the string form of the target', async () => { const request = buildRequest('GetMissingOnyxMessages', {updateIDFrom: 8102, updateIDTo: '8200'}); From 30dd3ec793e93ddb8f1b1957810c6a7710fc3b13 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Fri, 7 Aug 2026 21:50:36 +0200 Subject: [PATCH 10/10] Never read a null or empty update ID as the very first one Number(null) and Number('') are both a finite 0, so Number.isFinite let them through as update ID 0: a response carrying no lastUpdateID read as a stalled client, and a request with no updateIDTo stamped a target of 0. Both sites now share one reader that rejects those two shapes first. Co-Authored-By: Claude Opus 5 (1M context) --- src/libs/Middleware/SentryServerTiming.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/libs/Middleware/SentryServerTiming.ts b/src/libs/Middleware/SentryServerTiming.ts index 87204b40c87c..a185f17a6eb5 100644 --- a/src/libs/Middleware/SentryServerTiming.ts +++ b/src/libs/Middleware/SentryServerTiming.ts @@ -3,10 +3,8 @@ import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import {cancelSpan, endSpanWithAttributes, startSpan} from '@libs/telemetry/activeSpans'; import CONST from '@src/CONST'; -import type Request from '@src/types/onyx/Request'; import type {SpanAttributes} from '@sentry/core'; -import type {OnyxKey} from 'react-native-onyx'; import type Middleware from './types'; @@ -56,14 +54,14 @@ function findTrackedGroup(command: string): TrackedCommandGroup | undefined { return TRACKED_COMMAND_GROUPS.find((group) => group.commands.has(command)); } -function readUpdateIDTo(data: Request['data']): number | undefined { - const updateIDTo = Number(data?.updateIDTo); - return Number.isFinite(updateIDTo) ? updateIDTo : undefined; +function readUpdateID(value: unknown): number | undefined { + const updateID = value === null || value === '' ? Number.NaN : Number(value); + return Number.isFinite(updateID) ? updateID : undefined; } function didResponseAdvance(updateIDFrom: number | undefined, lastUpdateID: number | string | undefined): boolean | undefined { - const responseUpdateID = Number(lastUpdateID); - if (updateIDFrom === undefined || !Number.isFinite(responseUpdateID)) { + const responseUpdateID = readUpdateID(lastUpdateID); + if (updateIDFrom === undefined || responseUpdateID === undefined) { return undefined; } return responseUpdateID > updateIDFrom; @@ -89,7 +87,7 @@ const SentryServerTiming: Middleware = (response, request) => { attributes: { [CONST.TELEMETRY.ATTRIBUTE_COMMAND]: request.command, [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_FROM]: updateIDFrom, - [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_TO]: readUpdateIDTo(request.data), + [CONST.TELEMETRY.ATTRIBUTE_UPDATE_ID_TO]: readUpdateID(request.data?.updateIDTo), }, });