Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnableHotReload error handling #222

Closed
devna13 opened this issue Aug 19, 2021 · 3 comments
Closed

EnableHotReload error handling #222

devna13 opened this issue Aug 19, 2021 · 3 comments
Labels
closed-stale Closed because the issue got stale and there wasn't any follow-up. enhancement New feature or request help wanted Extra attention is needed stale

Comments

@devna13
Copy link

devna13 commented Aug 19, 2021

I'm new to this awesome repo, and using EnableHotReload to update plugins on the fly similar to your hot reload sample

  loader = PluginLoader.CreateFromAssemblyFile(
                            pluginDllPath,
                            sharedTypes: new[] {
                               typeof(IPluginMessageHandler),
                               //typeof(IServiceCollection),
                               typeof(ILogger)
                            },
                            isUnloadable: true,
                            configure: config => config.EnableHotReload = true);

everything works great but I ran into an edge case; If I publish a bad plugin, that doesn't have all of it's dependencies, it causes the host app to crash with this CLR exception

Fatal error. Internal CLR error. (0x80131506)
   at System.Runtime.Loader.AssemblyLoadContext.PrepareForAssemblyLoadContextRelease(IntPtr, IntPtr)
   at System.Runtime.Loader.AssemblyLoadContext.InitiateUnload()
   at System.Runtime.Loader.AssemblyLoadContext.Unload()
   at McMaster.NETCore.Plugins.PluginLoader.Reload()
   at McMaster.NETCore.Plugins.Internal.Debouncer+<>c__DisplayClass4_0.<Execute>b__0(System.Threading.Tasks.Task)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()

I was wondering if wrapping this line in try catch would resolve it, or there is a better way to prevent host from crashing

Reloaded?.Invoke(this, new PluginReloadedEventArgs(this));

Thanks

@devna13 devna13 added the question Further information is requested label Aug 19, 2021
@natemcmaster natemcmaster added help wanted Extra attention is needed enhancement New feature or request and removed question Further information is requested labels Nov 13, 2021
@natemcmaster
Copy link
Owner

I'll mark this as 'help wanted'. There are probably better ways to handle these errors and would be open to contributions to improve it.

(FYI - this project is in maintenance mode right now. See #117 for detail on what the applied labels indicate.)

@github-actions
Copy link

This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please comment if you believe this should remain open, otherwise it will be closed in 14 days. Thank you for your contributions to this project.

@github-actions github-actions bot added the stale label Nov 14, 2022
@github-actions
Copy link

Closing due to inactivity.
If you are looking at this issue in the future and think it should be reopened, please make a commented here and mention natemcmaster so he sees the notification.

@github-actions github-actions bot added the closed-stale Closed because the issue got stale and there wasn't any follow-up. label Nov 29, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-stale Closed because the issue got stale and there wasn't any follow-up. enhancement New feature or request help wanted Extra attention is needed stale
Projects
None yet
Development

No branches or pull requests

2 participants