fix case where websocket collision crashes frames #227
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Issue
Mentioned in #202, there is a case where successive calls to enable org-roam-ui-mode causes an address collision due to the websocket-server call triggering with each request to activate the mode.
This appears to happen with
desktop.el
but can also be triggered with the following steps if using DOOM emacs, and emacs daemon.emacsclient -c
emacsclient -c
In this case the behavior is a result of doom's theme-specific hooks resulting in successive calls of
(org-roam-ui-mode 1)
, which cause the websocket-server failure.Proposed solution
This PR creates a new custom variable to track the state of the webserver: t if running & nil if not. A call to enable the mode only launches the websocket-server if the server is not already running. If the server was already running at the time of the call, log to the Message buffer that the server was already running.