Skip to content

feat(tags): Cancel the current request before progressing refresh #517

Merged
MileaRobertStefan merged 17 commits intomainfrom
users/rmilea/2025/tagsdatasouce/cancel_request
Nov 17, 2025
Merged

feat(tags): Cancel the current request before progressing refresh #517
MileaRobertStefan merged 17 commits intomainfrom
users/rmilea/2025/tagsdatasouce/cancel_request

Conversation

@MileaRobertStefan
Copy link
Copy Markdown
Collaborator

@MileaRobertStefan MileaRobertStefan commented Nov 12, 2025

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.
demo2

✅ Checklist

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> to Observable<DataFrameDTO> throughout the query handling chain
  • Updated PostFn type definition to return Observable<T> instead of Promise<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>
Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 12, 2025

@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.

MileaRobertStefan and others added 3 commits November 12, 2025 16:17
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>
Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 12, 2025

@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.

@MileaRobertStefan MileaRobertStefan changed the title feet(tags): Cancel the current request before progressing refresh feat(tags): Cancel the current request before progressing refresh Nov 13, 2025
MileaRobertStefan and others added 2 commits November 17, 2025 10:44
Co-authored-by: saradei-ni <sorin.robert.aradei@emerson.com>
@MileaRobertStefan MileaRobertStefan merged commit 32a3f4e into main Nov 17, 2025
2 checks passed
@MileaRobertStefan MileaRobertStefan deleted the users/rmilea/2025/tagsdatasouce/cancel_request branch November 17, 2025 09:35
Ahalya-ni pushed a commit that referenced this pull request Nov 17, 2025
## [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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants