Skip to content

fix: add timeout mechanism for OpenServer Shutdown#330

Draft
mohammad-arif662 wants to merge 4 commits into
mainfrom
POFSP-1507
Draft

fix: add timeout mechanism for OpenServer Shutdown#330
mohammad-arif662 wants to merge 4 commits into
mainfrom
POFSP-1507

Conversation

@mohammad-arif662
Copy link
Copy Markdown
Contributor

@mohammad-arif662 mohammad-arif662 commented Feb 18, 2026

This PR adds a timeout to Shutdown() so the calling thread is not blocked if shutdown hangs. It adds 10-second timeout to Shutdown(). If shutdown hangs the method still returns after 10 seconds instead of blocking the thread.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 87.09677% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.11%. Comparing base (edc51a3) to head (72d1ebc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...nite.Simulator.Utils/Automation/AutomationUtils.cs 87.09% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #330      +/-   ##
==========================================
- Coverage   76.12%   76.11%   -0.01%     
==========================================
  Files          38       38              
  Lines        4083     4107      +24     
  Branches      488      488              
==========================================
+ Hits         3108     3126      +18     
- Misses        791      796       +5     
- Partials      184      185       +1     
Files with missing lines Coverage Δ
...nite.Simulator.Utils/Automation/AutomationUtils.cs 73.46% <87.09%> (+3.19%) ⬆️

... and 3 files with indirect coverage changes

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

@mohammad-arif662 mohammad-arif662 marked this pull request as ready for review February 18, 2026 12:43
@mohammad-arif662 mohammad-arif662 requested a review from a team as a code owner February 18, 2026 12:43
@mohammad-arif662
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a timeout mechanism to the Shutdown method, which is a valuable improvement to prevent the application from hanging. However, the current implementation has a critical flaw that could lead to resource leaks by not releasing the COM object if PreShutdown fails. I have provided a critical review comment with a suggested fix for this issue. Additionally, I've included a high-severity comment to address a style guide violation regarding a hardcoded timeout value.

Comment thread Cognite.Simulator.Utils/Automation/AutomationUtils.cs
Comment thread Cognite.Simulator.Utils/Automation/AutomationUtils.cs Outdated
@mohammad-arif662 mohammad-arif662 changed the title Add timeout mechanism for OpenServer Shutdown fix: add timeout mechanism for OpenServer Shutdown Feb 19, 2026
Copy link
Copy Markdown
Contributor

@abdullah-cognite abdullah-cognite left a comment

Choose a reason for hiding this comment

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

Lets hold off on this for now.

The timeout path in Shutdown() can return while shutdown is still running in the background. That leaves lifecycle state inconsistent: Initialize() currently uses Server != null as a readiness check, so during/after timeout it can observe stale state and either skip re-initialization incorrectly or race with ongoing cleanup.

Properly fixing this would require more rework than we had anticipated, so lets park this one for now. I wouldn't rate the need for this a high priority right now.

@mohammad-arif662 mohammad-arif662 marked this pull request as draft February 24, 2026 08:51
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.

2 participants