Skip to content

Conversation

@kmichalikk
Copy link
Contributor

Fixes #2291

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 hydrateResults to 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, making destroy() 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
grzanka previously approved these changes Dec 14, 2025
@kmichalikk kmichalikk force-pushed the @kmichalikk/destroy-worker-after-fetching-results branch from 1e03205 to 9d05a00 Compare December 15, 2025 21:36
@grzanka grzanka added this pull request to the merge queue Dec 16, 2025
Merged via the queue into master with commit e190ae7 Dec 16, 2025
11 checks passed
@grzanka grzanka deleted the @kmichalikk/destroy-worker-after-fetching-results branch December 16, 2025 12:25
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.

Handle proper termination of Geant4 workers

3 participants