Open adeverteuil opened 1 year ago
I think I found the bug. In the source code, the plugin attempts to get all the folders like this:
let joplinFolders: JopinFolders;
const folders = [];
do {
joplinFolders = await joplin.data.get(['folders']);
[build internal index of folders...]
}
} while (joplinFolders.has_more);
However, this is not the correct way to make paginated request; the page
query parameter is missing. When there are more than 100 items to return and joplinFolders.has_more
is true
, only page 1 is requested and the plugin enters an infinite loop.
I think this would work better:
let joplinFolders: JopinFolders;
const folders = [];
let pageNum = 1;
do {
joplinFolders = await joplin.data.get(['folders'], {"page": pageNum++});
[build internal index of folders...]
}
} while (joplinFolders.has_more);
Please note that I have not tested this and I'm not a Typescript or a Javascript programmer.
I also found two places in src/ui/screens.ts
where this infinite loop may happen:
https://github.com/joplin/plugin-email/blob/34fe1a48573316b9e055f0d04e625a0fc8dcc294/src/ui/screens.ts#L207
https://github.com/joplin/plugin-email/blob/34fe1a48573316b9e055f0d04e625a0fc8dcc294/src/ui/screens.ts#L331
References:
Hi @adeverteuil, Thanks very much for this great description of the issue.
However, this is not the correct way to make paginated request; the page query parameter is missing. When there are more than 100 items to return and joplinFolders.has_more is true, only page 1 is requested and the plugin enters an infinite loop.
This is correct; the bug occurs when the number of folders is greater than 100. I will fix it, and thank you for mentioning it.
To be sure, this is the issue you encounter. Is the login button going to always spin infinity, and you unable to login?
Hi @bishoy-magdy, thank you for your response!
Is the login button going to always spin infinity, and you unable to login?
Yes, when I click on the Login button, then it changes to a Loading spinner that spins infinitely, and I am unable to login.
Here is a screenshot:
@bishoy-magdy are you able to produce a new release from the latest code? The current 1.0.0 release is out of date and leading to loading/loop issues.
@bishoy-magdy Thank you for this plugin, it is the reason I moved from tidliwiki to Joplin. Could you please make a new release of the plugin from the latest code?
Hi,
I'm trying to configure the Email Plugin, but I think there is an infinite loop bug.
Email provider
I host my personal mailcow: dockerized mail server on DigitalOcean.
Steps to reproduce
Problem conditions
The problem does NOT happen on an empty Joplin profile.
If I change to a new profile and configure the plugin, it successfully logs in and imports notes from the mailbox.
Then, if I import my notes from the
.jex
backup into the new profile, it continues working and importing notes from the mailbox.But after importing my notes from the
.jex
backup, and try to logout and log back in with the Email plugin, the problem happens again.So I don't know if the bug is in Joplin or in the Email plugin. It seems to only happen when there are notes and notebooks present at the time of logging in. But I'm not sure how to isolate the exact minimal conditions to reproduce the issue.
Negative testing
I tried with the wrong password, and I got a popup message saying "Error: Authentication failed."
The infinite loop doesn't happen in that case.
Logs
I enabled debug logs by following these instructions. Here is an extract of the output, starting at the first instance of the string "Email".
This loop of
joplin.data.get
messages continues seemingly forever, at a rate of about 500 per second, and with repeating UIDs, until I stop the Joplin application.In Dovecot logs, I see a successful login, but then nothing else until I close the Joplin application.