Skip to content

fix: Subscription diagnostic nodes not deleted when disabling diagnostics#3559

Merged
marcschier merged 1 commit intoOPCFoundation:masterfrom
RicoSuter:fix/diagnostics-subscription-cleanup-bug
Feb 17, 2026
Merged

fix: Subscription diagnostic nodes not deleted when disabling diagnostics#3559
marcschier merged 1 commit intoOPCFoundation:masterfrom
RicoSuter:fix/diagnostics-subscription-cleanup-bug

Conversation

@RicoSuter
Copy link
Contributor

@RicoSuter RicoSuter commented Feb 16, 2026

Fix a bug in DiagnosticsNodeManager.SetDiagnosticsEnabled(false) where the subscription cleanup loop indexes m_sessions instead of m_subscriptions.

Disclaimer: This bug has been found with hours of manual work with AI and my local OPC UA stress test application and should be safe - please review the changes as I don't really know the OPC UA code base in depth.

Bug

When SetDiagnosticsEnabled(false) is called, the subscription cleanup loop at line 643-646 iterates m_subscriptions.Count but indexes m_sessions[ii]:

for (int ii = 0; ii < m_subscriptions.Count; ii++)
{
    nodesToDelete.Add(m_sessions[ii].Value.Variable); // should be m_subscriptions[ii]
}

This causes:

  • IndexOutOfRangeException when there are more subscriptions than sessions, preventing any cleanup
  • Wrong nodes deleted otherwise — session nodes are added to the delete list instead of subscription nodes

Subscription diagnostic nodes (and their child states and references) remain permanently in PredefinedNodes.

@RicoSuter RicoSuter changed the title fix: Subscription diagnostic nodes not deleted when diagnostics disabled fix: Subscription diagnostic nodes not deleted when disabling diagnostics Feb 16, 2026
@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.72%. Comparing base (d25caff) to head (c10cc07).
⚠️ Report is 118 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3559       +/-   ##
===========================================
+ Coverage   51.86%   64.72%   +12.85%     
===========================================
  Files         370      458       +88     
  Lines       78618    96773    +18155     
  Branches    13650    16264     +2614     
===========================================
+ Hits        40779    62637    +21858     
+ Misses      33705    29138     -4567     
- Partials     4134     4998      +864     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marcschier marcschier merged commit 6a837eb into OPCFoundation:master Feb 17, 2026
116 of 117 checks passed
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.

3 participants

Comments