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

anki-editor-api-check: Failed to connect to Anki: End of file while parsing JSON #5

Closed
doolio opened this issue Oct 27, 2022 · 3 comments

Comments

@doolio
Copy link

doolio commented Oct 27, 2022

This may not be a bug but it did not occur previously when on the master branch from louietan/anki-editor and the following config:

(use-package anki-editor
  :after org
  :demand t
  :config (anki-editor-mode))

(The use of :after and :demand here is because I lazy load my packages as much as possible.)

Switching to this fork my use-package form becomes:

(use-package anki-editor
  :straight (:fork "orgtre")
  :after org
  :demand t
  :config (anki-editor-mode))

So it seems with the merge of the louietan/anki-editor:develop branch Anki needs to be running to use the minor mode. This makes sense but it is odd I saw no such message when on the loueitan/anki-editor:master branch. Indeed the develop branch introduced changes to the API but nothing as yet stands out which would point to why I didn't see this message before.

@orgtre
Copy link
Member

orgtre commented Oct 29, 2022

Yes, I see the same behavior. This is because a function anki-editor-api-check has been introduced which is called in anki-editor-setup-minor-mode (which in turn is called by anki-editor-mode). I'd say this is fine. Or is there something we should change here? Maybe a clearer error message? Or given that there are some commands in anki-editor which don't really require Anki running, we might want to perform this check only when calling those that require it?

@doolio
Copy link
Author

doolio commented Oct 31, 2022

Maybe a clearer error message?

Yes, as a minimum I think.

Or given that there are some commands in anki-editor which don't really require Anki running, we might want to perform this check only when calling those that require it?

This makes sense.

orgtre added a commit that referenced this issue Nov 2, 2022
Increases user-friendliness, as discussed in #5.
@orgtre
Copy link
Member

orgtre commented Nov 2, 2022

After some consideration, I think it's best to settle with just the clearer message. Almost all commands anki-editor provides do in fact need Anki running. Adding the check to each command would add an extra API call to each, which is undesirable. I'm also consciously only adding the clearer error message to anki-editor-api-check. If Anki or AnkiConnect are closed down subsequently other commands will also fail with "End of file while parsing JSON", but we don't want to modify the error message each time as right now the error messages are generated outside anki-editor and simply passed on.

If you really want to avoid the call to anki-editor-api-check I suggest commenting that line. If more people are disturbed by this I guess we could add a custom option too in the future.

@orgtre orgtre closed this as completed Nov 2, 2022
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