Closed rchl closed 1 month ago
Logs on closing the last file of a session
Without the fix:
[DocumentListener] _clear_session_views_async
[Session] end_async False
[Session] Sending shutdown
[Session] Closing transport
[Session] __del__ LSP-typescript
[ProcessTransport] end Transport None
With the fix:
[DocumentListener] _clear_session_views_async
[Session] end_async False
[Session] Sending shutdown
[Session] Closing transport
[ProcessTransport] end Transport <LSP.plugin.core.sessions.Session object at 0x1058472b0>
[Session] on_transport-close
[WindowManager] on_post_exit_async LSP-typescript
[Session] __del__ LSP-typescript
Name | Link |
---|---|
Latest commit | cc7c42c185d3b128f45003c023c9bb0eba9955c2 |
Latest deploy log | https://app.netlify.com/sites/sublime-lsp/deploys/66f938a57f44000008a384b9 |
Deploy Preview | https://deploy-preview-2518--sublime-lsp.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Even after the changes:
WindowManager.destroy()
is called and it ends and removes all sessions from the set so the listeners are not called in this case. This is perhaps OK.WindowManager.restart_sessions_async()
is called and it also ends the session and removes it from the set immediately so the listeners are also not called. This might not be ideal since a proper cleanup might not happen. We have to also keep in mind that session can restart before the previous one fully shut down (https://github.com/sublimelsp/LSP/issues/2258) so doing a seemingly correct fix could introduce issues.
I was looking into introducing some global session listener concept for plugin use but while doing so I found out that on closing a session we don't trigger various lifecycle listeners that we should be triggering. It appears that
Session
is deleted beforeTransport
is closed soSession.on_transport_close
and following logic is not executed.The one-line fix is to change
self._sessions
inWindowManager
fromWeakSet[Session]
toset[Session]
.I'm not sure why we are using
WeakSet
here. There could be a valid reason when this makes sense or it could be due to old convention where we've relied more on GC than on explicitly notifying when Session/SessionView/SessionBuffer are closed.(I've also left a bunch of logs that I'm of course planning to remove but those can be used to see the difference with and without this fix when closing the last file of some session, for example.)