PowerShell / SecretManagement

PowerShell module to consistent usage of secrets through different extension vaults
MIT License
317 stars 46 forks source link

[1.1.0-preview] Cleanup of Runspaces at Unload/Reload -Force? #150

Closed JustinGrote closed 3 years ago

JustinGrote commented 3 years ago

Runspaces for the secret vaults do not appear to get removed/recycled when the module is unloaded or force reloaded image

This makes testing difficult because I have to manually:

  1. Maintain a list of runspace instanceIDs that aren't the module
  2. Look for the difference after loading
  3. Close that runspace after the test to ensure the next test runs clean without state.
PaulHigin commented 3 years ago

I don't see a good way to tie the lifetime of runspaces to whether the SM module is loaded, so they are currently static. Creating runspaces for each vault call instance would not be acceptable perf wise.

But in general you should always keep track of any runspaces you create so that you can dispose of them individually when needed. You should never dispose any runspaces of unknown origin.

JustinGrote commented 3 years ago

@PaulHigin this is purely within the scope of testing, I don't plan to do this operationally, it's just very annoying and drastically increased my inner loop is all :)