-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[Spa] Try additional hooks to kill the application #34427
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @javiercn.
This fix isn't bad at all. I think this very well be the long term fix that we need.
IOptions<SpaDevelopmentServerOptions> options) | ||
{ | ||
_options = options.Value; | ||
_logger = logger; | ||
appLifetime.ApplicationStopping.Register(() => Dispose(true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So SpaProxyLaunchManager is a service in DI but Dispose isn't getting called on app shutdown for some reason?
Who normally calls StopAsync?
Do you want to use ApplicationStopped instead? Requests may still be in flight otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tratcher the problem here is that the debugger kills the app and leaves the process running.
We don't get a chance to kill the SPA process ourselves. This change just brings the current implementation more inline with the old implementation, although I suspect both suffer from the same issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I recall correctly, the debugger kills processes in the rudest way possible with no chance to run shutdown logic. What you really need is a way to register the child process with the debugger as something it should also terminate. Maybe if you launched the child process with the debugger attached?
I see some prior art here:
#5204
#11597
#17883 (claims ApplicationStopping worked for them)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of this things work, people thought they worked because they didn't see the window (or didn't try with the debugger).
I found a reasonable solution which is simple enough I'm happy with. We launch a powershell process that monitors the .NET process and when it sees it die, it kills the npm process and all its children, and that does the trick.
… kill the SPA process if when it ends abruptly
5dcc39f
to
44416ed
Compare
Try a couple of additional hooks for killing the SPA proxy.
We got a report that the services remain alive after the debugger has stopped the process. The changes included here are the only two meaningful differences with the previous implemenation (here)