-
Notifications
You must be signed in to change notification settings - Fork 230
Yomichan Anki card creation isn't working #327
Comments
The Few questions:
This is probably a long shot guess, but maybe it's a firewall thing, so make sure nothing's blocking Anki. |
Late to the thread, but I was having the exact same issue as described above.
I have also followed the notes to disable the App Nap feature on Mac OS and disabled the firewall, but to no avail. |
There have been some recent changes to AnkiConnect, but there should not be be anything breaking. Here are some things to try: Can you access http://127.0.0.1:8765/ in your browser? From Anki, select Tools | Add-ons. Select AnkiConnect. Press the "Config" button on the right. Edit the configuration JSON to include a path for a log file. For example:
You would obviously need to update the path to something that makes sense on your system, and use |
I did have a log file show up in the directory I'm using, but can I get a clarification of what should I be doing in order to have the information logged into the file? Because so far, my log file is empty right now, despite me doing virtually everything that I think that would be related, like restarting Anki (and the whole computer), or restarting Chrome (which is has the Yomichan extension installed). |
@atran14 you should try to use the AnkiConnect enabled features of Yomichan (for example, simply enabling AnkiConnect should cause some stuff to show up in the log). Can you also verify what is displayed when you access http://localhost:8765 when AnkiConnect is running? |
http://localhost:8765 displays the message "AnkiConnect v.6" for me. |
This is the result that I have back from executing that piece of code
In addition, the log file has also been logged with the following by executing the above piece of code
However though, the Anki integration in Yomichan's settings is still displaying the "Error: Invalid response" message. |
Okay, from those values I don't see anything that looks immediately incorrect, so here is another script to try. This time, the code is taken directly from Yomichan's source code rather than trying to use a shortened version. (async () => {
function requestJson(url, action, params) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.overrideMimeType('application/json');
xhr.addEventListener('load', () => resolve(xhr.responseText));
xhr.addEventListener('error', () => reject(new Error('Failed to connect')));
xhr.open(action, url);
if (params) {
xhr.send(JSON.stringify(params));
} else {
xhr.send();
}
});
}
const results = [];
for (const action of ['version', 'deckNames', 'modelNames']) {
const text = await requestJson('http://127.0.0.1:8765', 'POST', {action, version: 2});
try { JSON.parse(text); } catch (e) { console.log(action, e); }
results.push(text);
}
console.log(JSON.stringify(results, null, 4));
})(); |
@toasted-nutbread the version is being sent as "2", that is incorrect, it should be "6". This is causing AnkiConnect to send back data in a deprecated format. |
Actually nevermind, Yomichan never needed to switch to the format which contained the additional response information... This is very strange. |
Apologies for the late reply. Here's the image of the console's output from executing the script In addition, here's the log:
|
This is quite strange indeed, everything appears to be working based on these results. The only other thing I can think to do is to try and edit the extension code to display more diagnostic information, but I don't know if you're comfortable doing that. Regardless, I think thinks merits adding some additional info to the "Invalid response" message. I also tweaked the request method recently in 7686e56 which hasn't worked its way into a new build yet, but I wouldn't think that would fix the issue. Thank you for helping to debug the issue thus far. |
@atran14 Another suspect is yomichan/ext/bg/js/settings/anki.js Line 66 in 1fd568a
The AnkiConnect code looks like it should handle asynchronous requests without issues, but the previous code waited for each of those to complete before running the next query. 5339381 |
I have added additional debugging information to the "Invalid response" message in 26ea278. The message on the settings page can be expanded to show extra data and a stack trace. With this, we should hopefully hopefully at least be able to see what response is triggering the issue. |
@siikamiika If memory serves me correctly, it was late last year. Anki integration with AnkiConnect was still working properly until recently. |
@atran14 Would be awesome if you could checkout master and test it with Anki! Just go to |
Looks like this may have also previously happened in #142, or something similar. |
Alright, I have been doing some messing around with the
So, at this point, I'm not really sure what kind of issue I'm dealing with here. |
@atran14 Are you able to export your settings from the stable version using "Backup" at the bottom of the settings and import them to the debugging version? edit: never mind if it was a fresh install already |
You have to select a model also. Try changing that and then the fields should appear. If that works, then it seems like the issue will be fixed with the next release, which is good. However, that doesn't really tell us what was broken in the first place. The only remaining thing that I can think of is the content-type override changing from |
I'll put out a testing version, and if that goes fine, I will promote it to official next weekend. |
An update: Fresh uninstall and install of the extension has apparently solved my problem now, but there's something I just noticed. For the context, I did, prior to this, export the my old settings from the stable version that was getting the "Invalid response" error. (Supplement 1: Restoring Yomichan back to its default settings also appears to solve the error message too) Do you guys mind if I upload the settings profile here? |
@atran14 |
Attached is the settings profile that was causing the "Invalid response" for me (You need to change the extension to |
It was missing You have to enable advanced options to see and edit the server address. |
So apparently an empty string requests a path relative to the background page, which is the background page itself. That's not valid JSON. |
That would explain the invalid response, since it's effectively requesting background.html. It may be a good idea for us to add a better message indicating why this might be happening. |
That completely solves the problem now. No more issues regarding with the error message anymore. |
@toasted-nutbread is it possible to ban an empty string in the schema like |
We could do that, but a message telling the user to adjust the Interface server option is probably the most foolproof. This will handle other cases, such as other relative URLS, or if a HTTP server is running on http://127.0.0.1:8765 which isn't Anki. |
Yeah, agreed. The verbose error message you added is also great for future bug reports. |
Friendly reminder @FooSoft that there is still a testing release waiting to be released on stable. #327 (comment) The only issue that I noticed in that release was #337, which sometimes causes some tags to not show up depending on the results mode, but I don't think this is a blocker. |
I have anki running with AnkiConnect, and I go into Yomichan's settings and click "enable anki integration", and it just says "Error: Invalid Response". It's not allowing me to select a deck to make cards with. I'm not sure why that's happening, I tried re-installing Yomichan and re-installing Ankiconnect and it didn't fix it. It used to work, but I recently ran CCleaner and it stopped working after that.
The text was updated successfully, but these errors were encountered: