Skip to content

Dashboard: Acknowledge asynchronous MFE refreshes - #253

Merged
harjotgill merged 1 commit into
coderabbit_micro_frontendfrom
codex/grafana-refresh-ack
Sep 17, 2026
Merged

harjotgill merged 1 commit into
coderabbit_micro_frontendfrom
codex/grafana-refresh-ack

Conversation

@harjotgill

@harjotgill harjotgill commented Sep 17, 2026 •

Copy link
Copy Markdown

Summary

  • keep the single-spa update lifecycle responsive while an opted-in host waits for a dashboard refresh
  • acknowledge refresh completion through metadata.eventListener with the dashboard UID, refresh revision, and success status
  • deduplicate in-flight dashboard revisions and discard late completions after unmount
  • preserve the awaited update behavior for hosts that do not send refreshCompletionMode: "event"

Root cause

PR #252 awaited the dashboard's variable refresh from the single-spa update lifecycle. A slow variable query therefore left the parcel in UPDATING, triggered single-spa's three-second lifecycle warning, and held later dashboard/navigation updates behind the same lifecycle.

This change makes asynchronous completion an explicit host opt-in. In event mode, the update dispatches the refresh and returns promptly. Grafana later emits:

{
  type: 'dashboardRefreshCompleted',
  data: { uid, refreshRevision, success },
}

Only successful completion advances the stored revision. The event contains no error details, query text, or SQL.

Compatibility and rollout

Deploy this provider change before the matching host change. An old host omits refreshCompletionMode and retains the existing awaited lifecycle behavior. The new host sends refreshCompletionMode: "event" only for refresh requests and waits for the matching event acknowledgment.

This is an ordered provider-first compatibility rollout because deploying the host first against the old provider would provide no completion event.

Validation

  • yarn jest public/app/fn-app/create-mfe.test.tsx public/app/features/variables/state/onTimeRangeUpdated.test.ts --runInBand — 24 tests passed
  • yarn eslint public/app/fn-app/types.ts public/app/fn-app/create-mfe.ts public/app/fn-app/create-mfe.test.tsx --no-cache — passed
  • Prettier check for the three changed files — passed
  • git diff --check — passed
  • yarn tsc --noEmit --pretty false — no diagnostics in changed files; the command remains nonzero with 122 diagnostics only in unchanged paths. These were not separately re-run on a clean base. The first unchanged error is public/app/features/variables/query/VariableQueryRunner.ts:202; the remainder are in the vendored public/app/plugins/panel/volkovlabs-table-panel tree (missing Volkov test packages and existing API/type drift).

Operational scope

  • no security, IAM, feature-flag, database, or configuration changes
  • normal CI, review, and merge queue apply
  • no admin merge requested

Summary by CodeRabbit

  • New Features

    • Dashboard refreshes can now report completion through success or failure events.
    • Added an optional event-based refresh completion mode.
  • Bug Fixes

    • Prevented duplicate refresh requests from being processed simultaneously.
    • Prevented outdated refresh results from overriding newer updates.
    • Refresh completions are safely ignored after the dashboard is unmounted.
    • Missing dashboard ownership now reports an unsuccessful result without causing an error.

@harjotgill
harjotgill merged commit bdec2e2 into coderabbit_micro_frontend Sep 17, 2026
3 of 4 checks passed
@harjotgill
harjotgill deleted the codex/grafana-refresh-ack branch September 17, 2026 02:35
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: c8024c66-1fff-4816-8dbf-14f975d6f604

📥 Commits

Reviewing files that changed from the base of the PR and between 769f2fe and 5fcfc5b.

📒 Files selected for processing (3)
  • public/app/fn-app/create-mfe.test.tsx
  • public/app/fn-app/create-mfe.ts
  • public/app/fn-app/types.ts

📝 Walkthrough

Walkthrough

The dashboard MFE now supports an opt-in refreshCompletionMode: 'event'. Event-mode updates return without awaiting refresh completion and emit dashboardRefreshCompleted events with the dashboard UID, revision, and success status. In-flight revisions are deduplicated, stale completions are ignored, and pending state is cleared on mount and unmount. Hosts without event mode retain awaited refresh behavior. Tests cover these paths.

Severity of issue fixed: Medium

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/grafana-refresh-ack
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch codex/grafana-refresh-ack

A rabbit reads each line,
The patch grows clear beneath the moon,
Small changes hop in place,
Tests guard the garden path,
Reviews bloom before the dawn.

Comment @coderabbitai help to get the list of available commands.

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.

1 participant