Destroy Geant4 worker when all result files have been fetched#2307
Merged
Destroy Geant4 worker when all result files have been fetched#2307
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements automatic cleanup of Geant4 workers after result files have been fetched, addressing issue #2291 to improve memory management. The implementation adds protection against concurrent hydration calls and gracefully handles worker destruction timing.
Key Changes
- Added early-exit check in
hydrateResultsto prevent re-hydration when results already exist - Wrapped file fetching in try-catch block to handle worker destruction from concurrent calls
- Introduced
markSafeForDeletion()method as the public API for worker cleanup, makingdestroy()private - Called
markSafeForDeletion()after successful result hydration to free worker resources
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/services/Geant4LocalWorkerSimulationService.ts | Added concurrent hydration protection and worker cleanup after results are stored; wrapped file fetching in try-catch for graceful error handling |
| src/Geant4Worker/Geant4Worker.ts | Introduced public markSafeForDeletion() method and made destroy() private to control worker lifecycle |
| src/Geant4Worker/Geant4DatasetDownloadManager.ts | Updated to use new markSafeForDeletion() API instead of directly calling destroy() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
grzanka
previously approved these changes
Dec 14, 2025
1e03205 to
9d05a00
Compare
grzanka
approved these changes
Dec 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2291