feat(tags): Cancel the current request before progressing refresh #517
feat(tags): Cancel the current request before progressing refresh #517MileaRobertStefan merged 17 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the tag datasource query handling to use RxJS Observables instead of Promises, enabling proper cancellation of ongoing requests when users click refresh. This addresses a bug where rapid refresh clicks would not cancel in-flight queries.
- Changed the query return type from
Promise<DataFrameDTO>toObservable<DataFrameDTO>throughout the query handling chain - Updated
PostFntype definition to returnObservable<T>instead ofPromise<T> - Modified all query handlers (
CurrentQueryHandler,HistoricalQueryHandler) to work with Observable patterns
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/datasources/tag/types.ts | Updated type definitions to use Observable instead of Promise for query operations |
| src/datasources/tag/TagDataSource.ts | Refactored runQuery and helper methods to return Observables with proper RxJS operators |
| src/datasources/tag/HistoricalQueryHandler.ts | Converted all async/await patterns to Observable chains with proper operators |
| src/datasources/tag/CurrentQueryHandler.ts | Updated to return Observable using of() operator |
| src/datasources/tag/QueryHandlerFactory.ts | Minor formatting change to constructor |
| src/datasources/tag/snapshots/TagDataSource.test.ts.snap | Updated test snapshots to reflect functional changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@MileaRobertStefan I've opened a new pull request, #519, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@MileaRobertStefan I've opened a new pull request, #520, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…s://github.com/ni/systemlink-grafana-plugins into users/rmilea/2025/tagsdatasouce/cancel_request
Co-authored-by: saradei-ni <sorin.robert.aradei@emerson.com>
## [4.67.0](v4.66.1...v4.67.0) (2025-11-17) ### Features * **tags:** Cancel the current request before progressing refresh ([#517](#517)) ([32a3f4e](32a3f4e))
Pull Request
🤨 Rationale
To fix the bug below
Bug 3463181: Grafana | Asset Data source | Refreshing data source queries before the currently running query is completed, the ongoing query is not cancelled as expected.
Whenever the user clicks refresh, the query route is getting called without cancelling the previous request.
👩💻 Implementation
Changed the query return type from Promise to Observable throughout the query handling chain
Updated PostFn type definition to return Observable instead of Promise
Modified all query handlers (CurrentQueryHandler, HistoricalQueryHandler) to work with Observable patterns
🧪 Testing
Updated all the tests to support observable return type.

✅ Checklist