feat: Implement extension deactivate
Description
Adds deactivate function to extension.ts that is called when extension is deactivated (editor closed, for example).
This will stop the LSP client. And stopping will send shutdown request to the LS. LS will handle this request and perform cleanup (e.g. stop ongoing workflows, etc.)
Related Issues
gitlab-org/editor-extensions/gitlab-lsp#1597 (closed)
How has this been tested?
- You can put a breakpoint in the
deactivateand from command palette callReload Window. It shouldpauseindeactivate. - Make sure to enable LSP tracing: Set in extension
settings.json-"gitlab-lsp.trace.server": "verbose", - Link the related LS MR that handles
shutdownrequest - Call
deactivatemanually, putting this small snippet at the end of theactivatefunction in theextension.ts
setTimeout(async () => {
await deactivate();
}, 10000);
After 10 seconds in the LS logs you'll see something like that: note the [REQUEST] shutdown and [ShutdownController] Performing cleanup
[Error - 20:14:44] Server process exited with code 1` but the `shutdown` request is still handled by the LS :shrug:
but if I put the breakpoint where it is sending the shutdown request to the LS
I can see that the shutdown request has reached the language server.
2025-10-29T20:22:33:924 [debug]: [REQUEST] shutdown - Params: {
"_isCancelled": false
}
2025-10-29T20:22:33:924 [debug]: [ShutdownController] Performing cleanup
2025-10-29T20:22:33:924 [debug]: [ExecutorManager] Disposing executor for workflow "".
2025-10-29T20:22:33:924 [info]: [DuoWorkflowNodeExecutor] Disposing executor
2025-10-29T20:22:33:924 [debug]: Requesting graceful workflow stop
2025-10-29T20:22:33:924 [debug]: [ExecutorManager] Disposing executor for workflow "1217330".
2025-10-29T20:22:33:924 [info]: [DuoWorkflowNodeExecutor][1217330] Disposing executor
2025-10-29T20:22:33:924 [debug]: Requesting graceful workflow stop
2025-10-29T20:22:33:924 [debug]: [REQUEST] shutdown - Result: null
[Trace - 20:22:33] Received response 'shutdown - (3)' in 3ms.
No result returned.
[Trace - 20:22:35] Sending notification 'exit'.
No parameters provided.
[Error - 20:23:16] Server process exited with code 1.
If you want to see that workflows are really clenauo up on shutdown - check the LS instructions
What CHANGELOG entry will this MR create?
-
fix:Bug fix fixes - a user-facing issue in production - included in changelog -
feature:New feature - a user-facing change which adds functionality - included in changelog -
BREAKING CHANGE:(fix or feature that would cause existing functionality to change) - should bump major version, mentioned in the changelog -
None - other non-user-facing changes
