jasonwilliams / anki

Anki VSCode Plugin
MIT License
273 stars 31 forks source link

The card cannot be updated, when there are more than 5 noteID annotations in the .md file #121

Closed Colbyzn closed 1 week ago

Colbyzn commented 7 months ago

Thanks for you, this tool is very useful!

Problem Description:

When I add a noteID annotation to a card in the .md document, everything goes smoothly until I add a noteID annotation to the sixth card, which does not get updated. Additionally, a prompt "Deck not sent: request to http://127.0.0.1:8765/failed, reason: connect ECONNREFUSED 127.0.0.1:8765" pops up in the bottom right corner of vscode.

Content of the .md document: image

JeffreyAnimal commented 6 months ago

Thanks for the Tool, indeed very useful. ❤️

Is anyone currently working on this Issue? On my tests with no initial notecardId after the 6th card all the Id's are null. So maybe there is a Issue with the Id allocation? Or could it be related to an Update of the Anki-Connector Plugin?

jasonwilliams commented 6 months ago

Thanks @JeffreyAnimal There’s currently no one working on this, I haven’t had much time but am always open to PRs or contributions.

JeffreyAnimal commented 3 months ago

After a bit of Testing it showed that the reason is not the request itself sent to the Anki Connector.

Maybe the Connector has a request Limit after whitch the connection is refused and returning "connect ECONNREFUSED 127.0.0.1:8765". Because sometimes on Debugging, the Error appears, but the 6th Card is still Updated.

A Idea would be to check if a Card value has been changed and only Update the Cards with changes. The Issue would still be, that only 5 or so Cards can be Updated simulaneously.

Another Idea would be to send only a limited amount of Update request and only send more, when the first few have been answered.

ccammack commented 3 weeks ago

I tried a deck of 1000 cards with the new release and could not reproduce this.

$ cat ./issue-121.sh 
#!/bin/sh
echo "# test"
i=0
while [ $i -lt $1 ]
do
  echo "## Front $i"
  echo "Back $i"
  i=$((i + 1))
done

$ chmod +x ./issue-121.sh

$ ./issue-121.sh 1000 > issue-121.md 

$ head -9 issue-121.md
# test
## Front 0
Back 0
## Front 1
Back 1
## Front 2
Back 2
## Front 3
Back 3

$ tail -9 issue-121.md
Back 995
## Front 996
Back 996
## Front 997
Back 997
## Front 998
Back 998
## Front 999
Back 999

I used "Anki: Send to own deck" to generate the IDs and send the deck to Anki, which took several minutes, but everything seemed to arrive okay.

$ head -9 issue-121.md
# test
## Front 0

<!-- notecardId: 1718073001824 -->
Back 0
## Front 1

<!-- notecardId: 1718073001829 -->
Back 1

$ tail -9 issue-121.md
Back 997
## Front 998

<!-- notecardId: 1718073009837 -->
Back 998
## Front 999

<!-- notecardId: 1718073009844 -->
Back 999

Screenshot from 2024-06-10 22-47-38

I don't think the card count itself is causing the problem; there must something else going on.

JeffreyAnimal commented 2 weeks ago

@ccammack The Issue isn't sending a new Deck to the Anki but Updating a existing Deck where the notecardId has already been set.

ccammack commented 2 weeks ago

Thanks, @JeffreyAnimal, I got it to happen about 2 minutes after starting the sync.

$ sed -i "s/## Front/## Front (changed)/g" issue-121.md
$ sed -i "s/Back/Back (changed)/g" issue-121.md
jasonwilliams commented 1 week ago

This has been fixed and released in https://github.com/jasonwilliams/anki/releases/tag/v.1.3.4