Skip to content

fix(backend/core): self-heal stale EdgeConfig cache on GetEdgeConfig - #3950

Open
Christoph-87 wants to merge 2 commits into
OpenEMS:developfrom
Christoph-87:fix/backend-stale-edge-config-self-heal
Open

Christoph-87 wants to merge 2 commits into
OpenEMS:developfrom
Christoph-87:fix/backend-stale-edge-config-self-heal

Conversation

@Christoph-87

Copy link
Copy Markdown
Contributor

Summary

  • When the Backend restarts and an Edge reconnects with a 1006/1008 WebSocket close code, the onOpen callback is skipped so the EdgeConfig cache is never repopulated
  • Subsequent GetEdgeConfig requests then returned an empty config, breaking the UI
  • Fix: in EdgeRpcRequestHandler.handleGetEdgeConfigRequest, if the cached config has no factories and the Edge is online, fetch the live config directly from the Edge via ComponentJsonApiRequest before responding

Test plan

  • EdgeRpcRequestHandlerTest.testGetEdgeConfig_returnsCache_whenFactoriesPresent — cached config with factories is returned directly
  • EdgeRpcRequestHandlerTest.testGetEdgeConfig_fetchesLive_whenFactoriesEmptyAndOnline — empty cache + online Edge triggers live fetch
  • EdgeRpcRequestHandlerTest.testGetEdgeConfig_returnsEmptyCache_whenFactoriesEmptyAndOffline — empty cache + offline Edge returns empty (no live fetch attempted)

Closes #3756

When the Backend restarts and an Edge reconnects with a 1006/1008 close
code, the onOpen callback is skipped and the EdgeConfig cache remains
empty. Subsequent GetEdgeConfig requests then returned an empty config.

Fix: if the cached config has no factories but the Edge is online, fetch
the live config directly from the Edge via ComponentJsonApiRequest before
responding.

Closes OpenEMS#3756
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #3950      +/-   ##
=============================================
+ Coverage      55.88%   55.91%   +0.03%     
- Complexity     19348    19360      +12     
=============================================
  Files           3705     3705              
  Lines         173321   173326       +5     
  Branches       14254    14256       +2     
=============================================
+ Hits           96844    96893      +49     
+ Misses         72641    72588      -53     
- Partials        3836     3845       +9     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Backend keeps serving a stale/factory-less EdgeConfig → all component settings forms render blank, with no self-heal until the Edge is restarted

1 participant