Repository navigation
feat(analytics-api): allow aborting analytics requests with an AbortSignal - #1879
Merged
Merged
Conversation
Let callers pass an AbortSignal in an options argument to the analytics API methods, so a request that is no longer needed can be aborted and its response is not downloaded. AnalyticsBase.fetch() and get() read options.signal and pass it to dataEngine.query() next to the variables. fetch() already took an options object for sorting dimensions, so the signal goes into that same object and existing callers keep working. Every public method (events, enrollments, tracked entities, aggregate) takes an optional second options argument and forwards it to fetch(), or to get() for getAggregate(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This was referenced Nov 5, 2026
HendrikThePendric
added a commit
to dhis2/individual-data-visualizer-app
that referenced
this pull request
Nov 5, 2026
Each analytics request aborts the one before it, and the hook ignores whatever an aborted request returns, so only the newest page or sort reaches the table. The hook also reports the page and page size of the request that is loading. The browser only stops the aborted request once @dhis2/analytics passes the signal on (dhis2/analytics#1879). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edoardo
approved these changes
Nov 9, 2026
dhis2-bot
added a commit
that referenced
this pull request
Nov 9, 2026
# [29.9.0](v29.8.2...v29.9.0) (2026-11-09) ### Features * **analytics-api:** accept an abort signal in analytics requests ([#1879](#1879)) ([cbd9a66](cbd9a66))
Contributor
|
🎉 This PR is included in version 29.9.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
HendrikThePendric
added a commit
to dhis2/individual-data-visualizer-app
that referenced
this pull request
Nov 10, 2026
Each analytics request aborts the one before it, and the hook ignores whatever an aborted request returns, so only the newest page or sort reaches the table. The hook also reports the page and page size of the request that is loading. The browser only stops the aborted request once @dhis2/analytics passes the signal on (dhis2/analytics#1879). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HendrikThePendric
added a commit
to dhis2/individual-data-visualizer-app
that referenced
this pull request
Nov 10, 2026
* feat: type the line list pager with and without totals The analytics pager has a page count and total when totals are requested, and isLastPage otherwise. Paging now always sends the page size, so a chosen page size is kept when moving to another page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: add the line list row count text Uses the program's or tracked entity type's plural label when there is one, and the standard words otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: request line list totals when the server can count them The server reports through capability.analyticsTotalCounts in system/info whether it can count line list rows cheaply. The app adapter already puts system info in the config, so the plugin reads it without an extra request. An empty page after the first one keeps the current page instead of showing an error, since without totals the user can go past the last page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: add the line list page input Typing a page and pressing Enter or leaving the field goes to that page. With totals, a page out of range goes to the nearest valid one. The page number boxes have a fixed width, so the buttons beside them don't move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: add the line list page size menu Rows per page moves out of the bar into a popover behind a button at its end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: replace the line list pagination with a custom bar Previous and next sit at the start of the bar, so they don't move when the table width changes between pages. The page number can be typed. With totals, the bar shows the page count and the total number of rows; on a single page it always shows the row count. Rows per page moves into a menu at the end of the bar. The bar is disabled while a page loads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: update translations for the line list pagination bar Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep the line list loader in view when the table is scrolled The loader was positioned inside the scrolling content, so it scrolled away with the rows. The sticky header and pager then stayed clickable while data loaded. The scroll box now renders the loader in a frame around the scrolling part. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: abort a line list request when a newer one starts Each analytics request aborts the one before it, and the hook ignores whatever an aborted request returns, so only the newest page or sort reaches the table. The hook also reports the page and page size of the request that is loading. The browser only stops the aborted request once @dhis2/analytics passes the signal on (dhis2/analytics#1879). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: keep paging and sorting usable while the line list loads The pager pages on from the page that is loading, so clicking next three times goes from page 1 to 4. The loader lets clicks through to the sort buttons and the pager, and nothing is disabled while loading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: page through each line list output type with and without totals Each output type queries its own analytics endpoint, so events, enrollments and tracked entities each get a paging test without and with totals. The tests force the analyticsTotalCounts capability through /api/system/info, so they run whatever analytics database the instance uses. The enrollment test with totals stays skipped while core answers that query with E7154. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: alert when a typed line list page has no rows Without totals the user can type a page past the last one. The table keeps the page it shows, and an alert says which page was not found and which page the user is back on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: block the next page button while a page loads without totals Without totals only a response tells whether the page after it exists, so rapid clicks on next could run past the last page. Next is marked aria-disabled instead of disabled while a page loads, so it keeps its focus and a keyboard user can press it again once the page is there. With totals the page count is known and next stays usable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: update translations for the empty page alert Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep the line list page size when sorting Sorting refetched without a page size, so the line list went back to 100 rows a page. A fetch without a page size now uses the last one requested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep the line list loader inside the scroll box border The loader covered the whole scroll box, border and scrollbars included. It now covers only the visible part of the table, measured from the scroll container, as it did before it was moved out of the scrolling content. The scroll box takes an isFetching flag and renders the loader itself. The loader is a plain div rather than a Cover, because Cover exists to catch clicks and this one lets them through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: name the E2E paging helper after the page it goes to Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: drop line list paging tests that the bar and slot specs cover The line list spec keeps one test that the response's pager reaches the bar, and one that the connection status does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: check the line list requests its data only once A fetch callback whose identity changes on every render would make the plugin refetch after each response. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: pass the empty page alert message to useAlert inline This needs dhis2/app-runtime#1447, which keeps useAlert's show function the same across renders. With older versions, show changes on every render and the line list would refetch in a loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: rename PageRequest to RequestedPage Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(deps): bump @dhis2/analytics to v29.9.0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(deps): bump @dhis2/app-runtime to v3.17.6 Brings the aborted FetchError for aborted requests (#1446) and a stable useAlert show function (#1447). Also dedupes the lockfile, so the app shell and @dhis2/ui use the same app-runtime as the app. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Related to DHIS2-22407
Relates to dhis2/app-runtime#1446, but doesn't depend on it (see below).
Key features
optionsargument with asignal(AbortSignal), which is passed on todataEngine.queryDescription
In the Individual Data Visualizer line list, a user who clicks "next page" several times in a row on a slow network only needs the last page. The requests for the pages in between should be aborted so their responses aren't downloaded. The data engine already accepts a
signal, but this library never passed one.AnalyticsBase.fetch(req, options)andget(req, options)passoptions.signaltodataEngine.query.fetchalready took anoptionsobject for sorting dimensions, so the signal is one more key in that object and existing callers don't change.events.getAggregate/getCount/getCluster/getQuery,enrollments.getAggregate/getQuery,trackedEntities.getQuery, andaggregate.getDataValueSet/getRawData/getDebugSql/getOutliersData.getAggregategoes throughget, the others throughfetch.Aborting only stops the client from downloading the response. The server usually keeps running the query.
Relation to dhis2/app-runtime#1446
The two PRs are related but don't depend on each other, and either can be merged and released first.
fetch, so the request is cancelled. An aborted request rejects with whatever error the data engine gives; this PR doesn't catch or wrap it.FetchErrorof typeaborted. Before it, the data engine (3.17.4 and earlier) rejects with typenetwork, with the browser'sAbortErrorindetails.The app needs both to cancel requests and get the right error back. The error comes from the data engine in the app's own
@dhis2/app-runtime, so this package doesn't need another release once app-runtime is fixed. Until then, the app can detect aborts withsignal.aborted.TODO
event-visualizer-app🤖 Generated with Claude Code