When writing an email, Mail should create one draft and update it regularly as I type it.
When writing an email, Mail creates a new draft every few seconds:

Mail app version: 1.5.1
watch the nextwork log as you compose and see if the UID returned by one draft is sent with the request of the next
drafId is constantly incremented
do you see anything like Draft <UID> could not be loaded in your logs?
No, no such messages.
But I see:
mailbox 4 synchronized, 12 new, 21 changed and 2 vanished messages
envelope 476 removed from mailbox list mutations.js:296
envelope 475 removed from mailbox list
mailbox 4 is my draft folder and envelope 476 and 475 relate to the draft I'm currently editing...
Open the browser network log and the a tail -f of your nextcloud.log. Set logging to debug. What are the entries logged for the request that stores the new draft?
Other lines to look out for: Account has no draft mailbox set, can't delete the draft, 'Could not flag draft as deleted and Could not expunge drafts folder
No, no such messages:
Nov 4 11:52:27 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:27+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"richdocuments","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:27 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:27+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"files_sharing","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:27 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":1,"time":"2020-11-04T10:52:27+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Updating draft <503> in account <1>","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Built range for findAll: min=1 max=165 total=93 totalRange=165 estimatedPageSize=8871 lower=165 upper=165 highestKnownUid=164","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Initial sync 1:Drafts - fetch all messages from IMAP took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Initial sync 1:Drafts - persist messages in database took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Initial sync 1:Drafts took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Account 1 has 400 messages for threading","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Threading 400 messages - build ID table took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Threading 400 messages - build root container took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Threading 400 messages - free ID table took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Threading 400 messages - prune containers took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Threading 400 messages - group by subject took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Threading 400 messages took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Account 1 has 369 threads","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:28 vm-cyrille-debian Nextcloud[62661]: {"reqId":"RKDTNxR1NObjOYndnjMh","level":0,"time":"2020-11-04T10:52:28+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Account 1 has 0 messages with a new thread IDs","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:30 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:30+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"richdocuments","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:30 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:30+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"files_sharing","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:30 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":1,"time":"2020-11-04T10:52:30+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Updating draft <504> in account <1>","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Built range for findAll: min=1 max=166 total=93 totalRange=166 estimatedPageSize=8925 lower=166 upper=166 highestKnownUid=165","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Initial sync 1:Drafts - fetch all messages from IMAP took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Initial sync 1:Drafts - persist messages in database took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Initial sync 1:Drafts took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Account 1 has 401 messages for threading","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Threading 401 messages - build ID table took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Threading 401 messages - build root container took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Threading 401 messages - free ID table took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Threading 401 messages - prune containers took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Threading 401 messages - group by subject took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Threading 401 messages took 0s","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Account 1 has 370 threads","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Nov 4 11:52:31 vm-cyrille-debian Nextcloud[62661]: {"reqId":"2ksapFVPJWe9akZIRLEs","level":0,"time":"2020-11-04T10:52:31+00:00","remoteAddr":"192.168.0.9","user":"admin","app":"mail","method":"POST","url":"/nextcloud/index.php/apps/mail/api/accounts/1/draft","message":"Account 1 has 0 messages with a new thread IDs","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"21.0.0.1"}
Sounds like the back-end is ok. Maybe the front-end list just stays outdated?
We've had the very same discussion before, I think. This feels like a dejavu.
I can reproduce this issue on master. Another finding: When I open the outdated drafts they don't load and I get the following output in the browser console:
[DEBUG] mail: the draft ID changed, we have to fetch the draft {app: "mail", uid: "admin", currentId: "no draft currently loaded", newId: 78}
xhr.js:184 GET http://localhost/index.php/apps/mail/api/messages/78/body 404 (Not Found)
ConsoleLogger.js:54 [ERROR] mail: could not load draft 78 {error: TypeError: Cannot read property 'databaseId' of undefined}
Only the most recent on can be displayed and contains the correct text. It seems like the old drafts are deleted from the backend but stay in the vue store.
Yes, indeed, dejavu.
Am I the only one seeing such behaviour?!?
Today, the 2 drafts that I've created didn't create "ghosts":

However, though the drafts folder is now OK for what concerns those 2 drafts, it was NOT OK when I was writing them: When I was writing a new email, while in the drafts folder, I could see my envelope list growing a bit erratically with "ghost" drafts being created, and then sometime, shrink back to a somewhat normal size, deleting all/most of the ghost drafts... Eventualy, leading to a correct situation now.
However, one can see in my screenshot that it's not the case for the draft I wrote 2 days ago: there are still now a lot of ghost drafts in the envelope list.
Also, here's my Drafts folder on my mail server for the last 2 days:
-rw------- 1 vmail vmail 3508 Nov 2 14:31 '1604323861.M316879P98120.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 14:33 '1604324005.M128782P98191.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 14:37 '1604324222.M359823P98265.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 15:07 '1604326027.M277748P98975.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 15:10 '1604326259.M535092P99129.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 15:20 '1604326832.M136572P99297.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 15:29 '1604327392.M360758P99491.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 15:41 '1604328101.M135515P99774.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 15:56 '1604328972.M489615P100047.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 16:07 '1604329639.M830561P100370.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 16:11 '1604329915.M232862P100539.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 16:16 '1604330178.M2988P100617.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 17:49 '1604335778.M756934P102555.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 17:53 '1604336010.M238014P102635.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 17:59 '1604336379.M3446P102754.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 18:01 '1604336513.M378659P102930.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 18:03 '1604336598.M972708P102974.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 18:07 '1604336828.M881773P103052.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 18:21 '1604337662.M571725P103500.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 18:33 '1604338401.M692878P103764.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 18:37 '1604338651.M640749P103965.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 18:42 '1604338962.M160712P104233.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 18:46 '1604339172.M409046P104316.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 18:50 '1604339406.M58208P104408.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3508 Nov 2 18:54 '1604339673.M709809P104549.vps612142,S=3508,W=3610:2,DS'
-rw------- 1 vmail vmail 3939 Nov 4 09:05 '1604477105.M264295P170594.vps612142,S=3939,W=4046:2,DS'
-rw------- 1 vmail vmail 859 Nov 4 09:25 '1604478343.M564294P171181.vps612142,S=859,W=891:2,DS'
-rw------- 1 vmail vmail 1007 Nov 4 11:52 '1604487151.M176783P175321.vps612142,S=1007,W=1047:2,DS'
root@vps612142:/var/vmail/cyrille/Maildir/Drafts/cur#
I can reproduce this issue on master.
Good, I'm not alone with this issue 馃槅
When I open the outdated drafts they don't load and I get the following output in the browser console:
Yes, I've noticed that also.
I'm now hosting my own mail server. So, maybe, this can help understanding the issue too....
Same issue here, same problem with 1.5.1 and 1.6.
I'm on mailbox.org, but I had the same issues with gmail as well.
Only the latest draft is saved to the server (most of the time, sometimes there are some leftover drafts).
I'm on an raspberry pi, if that makes a difference?
fyi - It seems this is still ongoing with version 1.7; the drafts, typing out one message with a previously empty drafts folder creates a screen full (as shown) which after a few minutes updates to two copies of the same draft. Reopening the folder reproduces the screen full.

Versions
Is there some information I can gether that might help?
Same for me.
which after a few minutes updates to two copies of the same draft. Reopening the folder reproduces the screen full.
Yes, that's exactly the behaviour I'm experiencing. Though, sometime, reopening the folder doesn't reproduces the screen full.
Same issue.Nextcloud 20.0.2, Mail 1.7.0.
If I open the mail with another mail client, the draft mails not appear repeated, only once.
If I open the mail with another mail client, the draft mails not appear repeated, only once.
Interesting. So on IMAP the messages exists just once?
@ChristophWurst , I've 2 nextcloud instances both pointing to the same IMAP account.
When I write a draft on 1 instance while having the "Drafts" folder open, I can see the envelope list being filled with tons of drafts:

While I can't see this behaviour on my other NC instance:

So this really seems to be a problem on the frontend. I will take a look at the composer and try to fix this.
Here's my DB while typing my draft:
MariaDB [nextcloud]> select id, uid, sent_at, flag_deleted,subject subject from oc_mail_messages where subject='test delete' order by sent_at;
+------+-----+------------+--------------+-------------+
| id | uid | sent_at | flag_deleted | subject |
+------+-----+------------+--------------+-------------+
| 1428 | 719 | 1606137959 | 0 | test delete |
| 1429 | 720 | 1606137962 | 0 | test delete |
| 1430 | 721 | 1606137970 | 0 | test delete |
| 1431 | 722 | 1606137973 | 0 | test delete |
| 1432 | 723 | 1606137976 | 0 | test delete |
| 1433 | 724 | 1606137983 | 0 | test delete |
| 1434 | 725 | 1606137986 | 0 | test delete |
| 1435 | 726 | 1606137998 | 0 | test delete |
| 1436 | 727 | 1606138003 | 0 | test delete |
+------+-----+------------+--------------+-------------+
9 rows in set (0.001 sec)
and a few seconds later:
MariaDB [nextcloud]> select id, uid, sent_at, flag_deleted,subject subject from oc_mail_messages where subject='test delete' order by sent_at;
+------+-----+------------+--------------+-------------+
| id | uid | sent_at | flag_deleted | subject |
+------+-----+------------+--------------+-------------+
| 1436 | 727 | 1606138003 | 0 | test delete |
+------+-----+------------+--------------+-------------+
1 row in set (0.001 sec)
after a few more edits:
MariaDB [nextcloud]> select id, uid, sent_at, flag_deleted,subject subject from oc_mail_messages where subject='test delete' order by sent_at;
+------+-----+------------+--------------+-------------+
| id | uid | sent_at | flag_deleted | subject |
+------+-----+------------+--------------+-------------+
| 1438 | 729 | 1606138151 | 0 | test delete |
| 1439 | 730 | 1606138154 | 0 | test delete |
+------+-----+------------+--------------+-------------+
2 rows in set (0.000 sec)
an a few minutes later:
MariaDB [nextcloud]> select id, uid, sent_at, flag_deleted,subject subject from oc_mail_messages where subject='test delete' order by sent_at;
+------+-----+------------+--------------+-------------+
| id | uid | sent_at | flag_deleted | subject |
+------+-----+------------+--------------+-------------+
| 1439 | 730 | 1606138154 | 0 | test delete |
+------+-----+------------+--------------+-------------+
so it settled to a correct situation eventualy
the user interface somewhat reflects these states
The DB should somewhat reflect the state on IMAP. And if the front-end catches up with that everything should be fine :wink:
hmm. Could it be that the code to cleanup the database isn't called when sending the draft?
I've updated my draft a little, sent it, and switched to my inbox folder, and now the DB stays with 12 entries for this draft (15 minutes after the draft being sent) :
MariaDB [nextcloud]> select id, uid, sent_at, flag_deleted,subject subject from oc_mail_messages where subject='test delete' order by sent_at;
+------+-----+------------+--------------+-------------+
| id | uid | sent_at | flag_deleted | subject |
+------+-----+------------+--------------+-------------+
| 1442 | 731 | 1606139362 | 0 | test delete |
| 1443 | 732 | 1606139370 | 0 | test delete |
| 1444 | 733 | 1606139373 | 0 | test delete |
| 1445 | 734 | 1606139377 | 0 | test delete |
| 1446 | 735 | 1606139385 | 0 | test delete |
| 1447 | 736 | 1606139389 | 0 | test delete |
| 1448 | 737 | 1606139397 | 0 | test delete |
| 1449 | 738 | 1606139401 | 0 | test delete |
| 1450 | 739 | 1606139404 | 0 | test delete |
| 1451 | 740 | 1606139407 | 0 | test delete |
| 1452 | 741 | 1606139411 | 0 | test delete |
| 1453 | 742 | 1606139414 | 0 | test delete |
+------+-----+------------+--------------+-------------+
12 rows in set (0.001 sec)
re-opening my draft folder and waiting a bit cleaned the database => no more old entries:
`MariaDB [nextcloud]> select id, uid, sent_at, flag_deleted,subject subject from oc_mail_messages where subject='test delete' order by sent_at;
Empty set (0.000 sec)
`
Ok now I'm confused. The frontend is healthy after all but the db cache is not updated properly. Seems like triggering a sync (or just waiting for the next one) resolves this problem.
yes, it's more like if the code to cleanup the db cache (at \OCA\Mail\Listener\DeleteDraftListener) ~isn't called in particular cases~.... is never called in particular cases
I found the bug and fixed it. Will clean up my code and send a PR asap.