Skip to content

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?

  1. You can put a breakpoint in the deactivate and from command palette call Reload Window. It should pause in deactivate.
  2. Make sure to enable LSP tracing: Set in extension settings.json - "gitlab-lsp.trace.server": "verbose",
  3. Link the related LS MR that handles shutdown request
  4. Call deactivate manually, putting this small snippet at the end of the activate function in the extension.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

⚠️ Note, that I have not figured what else is stopping the client from the normal shutdown. Because it will show in the LS logs

[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

Screenshot_2025-10-29_at_20.24.34

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
Edited by Olena Horal-Koretska

Merge request reports

Loading