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

[Windows] BackendApplicationContribution#onStop not called when terminated #14216

Open
haydar-metin opened this issue Sep 25, 2024 · 1 comment

Comments

@haydar-metin
Copy link
Contributor

Bug Description:

BackendApplication
The BackendApplication is responsible for starting and stopping contributions and includes listeners for termination signals like SIGTERM and SIGINT.

Scenario with --no-cluster
When running the application with the --no-cluster flag, the backend does not fork and runs in the same process. We can see the relevant code here. In this scenario, if the application exits, the exit handler in the BackendApplication is triggered, which calls the onStop method to properly shut down the contributions. This behavior is consistent across both Windows and Linux.

Scenario without --no-cluster
When the application runs without the --no-cluster flag, the BackendApplication operates in a forked process. If the Electron application is closed, the following code is executed: Electron Main Application Code, which uses process.kill to terminate the process.

Differences Between Linux and Windows
As documented in the Node.js documentation, in Linux, process.kill sends a signal to the process, while in Windows, there is no true signal; instead, the process is immediately terminated.

The Core Issue
The main problem is that the #onStop method of the contributions is not being called - because the backend is terminated immediately, meaning cleanup does not occur on Windows. In line 691, instead of using process.kill, we should gracefully shutdown the BackendApplication and allow the contributions to clean (e.g., onStop) itself.

Expectation
Contributions can clean up (#onStop is called) after terminating the application in Windows without using the --no-cluster flag.

Steps to Reproduce:

[0. If using the Debugger, then remove the --no-cluster from the launch.config]

  1. Add in https://github.com/eclipse-theia/theia/blob/v1.53.0/examples/api-samples/src/node/sample-backend-app-info.ts#L25 an onStop method
  2. Add a console.log (+ unsetRootLogger) there or use the debugger and start the application in Windows
  3. Close Electron

=> No log / breakpoint

Additional Information

  • Operating System: Windows 10
  • Theia Version: 1.53
@haydar-metin haydar-metin changed the title Windows does not call #onStop for BackendApplicationContribution when terminated [Windows] BackendApplicationContribution#onStop not called when terminated Sep 25, 2024
@dmm9
Copy link

dmm9 commented Oct 2, 2024

I guess this is the same as this discussion: #12135

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

No branches or pull requests

2 participants