-
Notifications
You must be signed in to change notification settings - Fork 537
fix: Resolve race condition causing incorrect edge list intermittently on Overview page. #3432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…rmittently when navigating back Overview page.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3432 +/- ##
=============================================
- Coverage 59.78% 59.63% -0.15%
Complexity 112 112
=============================================
Files 2870 2894 +24
Lines 124042 124658 +616
Branches 9298 9343 +45
=============================================
+ Hits 74152 74324 +172
- Misses 47097 47524 +427
- Partials 2793 2810 +17 🚀 New features to boost your workflow:
|
85063b6 to
7ad2041
Compare
7ad2041 to
a6db83c
Compare
I moved the initialization logic from ionViewWillEnter to the constructor to prevent a race condition. This change causes this.router.navigate() to be called immediately when TestBed.createComponent() instantiates the component. Since the original test setup did not mock the Router, this immediate navigation threw an NG04002 error. |
lukasrgr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thx for your contribution
Couldn' t recreate the suggested behaviour
Thx for the very detailed description
|
i never had this issue aswell (1500 virtual Edges) |
|
Based on my extensive testing, I found that the issue on the overview page is highly reproducible with the latest public version of the OpenEMS code. For instance, the bug is easy to trigger in my test environment when simulating 22 virtual edges. |
I attempted to reproduce this issue following the steps you described, including:
Unfortunately, I was unable to reproduce the reported behavior on my end. However, upon reviewing your video, I noticed that not all filter options are being used. This leads me to believe the issue might be related to the filter restoration logic, which could also be connected to #3443. Could you provide more details about your specific test environment (browser, Angular/Ionic versions) and the exact filter configuration that triggers this behavior? |
|
Thank you for looking into this. |
Thank you. Since you mentioned the bug occurs with default configuration (no custom filters applied), could you confirm:
|
|
Ahhhhh,
Why the Bug Only Occurs with MetadataDummy MetadataDummy (line 357-359): MetadataOdoo (line 624-628): The Race Condition Mechanics With MetadataDummy:
With Odoo:
The bug is real but only manifests with MetadataDummy because instant responses create a timing window for the race. Production Odoo backends have sufficient latency to mask the issue. However, the fix is still architecturally correct and prevents potential future issues (e.g., if Odoo responses become faster through caching). |



Description
Problem
An intermittent issue was observed on the Overview page.
When navigating back from one edge Live/History page, the Overview sometimes displayed unexpected filtered Edge instead of the full edge list.
This bug appeared only occasionally, making it difficult to reproduce consistently.
Root Cause
The issue was caused by a race condition between the parent component's lifecycle and the child component's event emission:
I think this race condition caused by ionViewWillEnter() running too late in the lifecycle, giving the child component a chance to apply stale filters before the parent resets its state.
The initialization logic (resetting page, filteredEdges, and calling init()) was placed in ionViewWillEnter(). Since Ionic caches views, this hook triggers every time the view becomes active (including navigating back), causing the component to unnecessarily reset its state and reload the list.
Simultaneously, the child component restores its previous state and triggers a filtered search via searchOnChange().
Because both flows run independently:
• Sometimes the parent wins → unfiltered list is displayed → correct
• Sometimes the child wins → stale filter overwrites parent state → unexpected edge
This explains the intermittent nature of the bug and why it is not consistently reproducible.
Solution
Move initial state reset and metadata subscription from ionViewWillEnter() to constructor.
The constructor runs only once when the component is instantiated.
This ensures the initial state is set deterministically.
When navigating back to the Overview, the component simply displays its cached state without re-triggering the initialization logic. This effectively eliminates the race condition, as the parent no longer attempts to reset itself in parallel with the child component.