1
0
Fork 0
mirror of https://git.sr.ht/~rjarry/aerc synced 2025-11-16 22:51:11 +01:00
aerc/worker/jmap
Matěj Cepl 560c310648 jmap: fix infinite loop when fetching messages in a large folder
When fetching message headers in a large folder, aerc could enter an
infinite loop, repeatedly fetching the same message metadata. This was
caused by a bug in the JMAP worker's message fetching logic.

The `handleFetchMessageHeaders` function in `worker/jmap/fetch.go`
iterates over a slice of emails (`currentEmails`) to identify threads
that need to be fetched. If a thread was already cached, the code would
then iterate over all emails within that thread and append them to the
`currentEmails` slice.

Appending to a slice while iterating over it is a classic Go pitfall
that can lead to unexpected behavior. In this case, it caused the loop
to re-process the same emails repeatedly, leading to an infinite loop of
`Email/get` requests for the same message ID.

This patch fixes the bug by removing the line that appends to the
`currentEmails` slice inside the loop. The UI is still updated with the
information about the emails in the cached thread, but the main loop
does not grow and the infinite loop is avoided.

Signed-off-by: Matěj Cepl <mcepl@cepl.eu>
Tested-by: Tristan Partin <tristan@partin.io>
Reviewed-by: Tristan Partin <tristan@partin.io>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-10-30 21:11:27 +01:00
..
cache jmap: cache threads 2024-12-21 16:49:31 +01:00
configure.go jmap: fix crash when opening multiple instances 2023-07-15 17:09:49 +02:00
connect.go jmap: start listening for changes on Connect message 2024-12-21 16:49:14 +01:00
directories.go jmap: rely on updates to update mailbox list 2024-12-21 16:49:14 +01:00
fetch.go jmap: fix infinite loop when fetching messages in a large folder 2025-10-30 21:11:27 +01:00
jmap.go treewide: replace uint32 uids with opaque strings 2024-08-28 12:06:01 +02:00
push.go jmap: explicitly fetch body structure subparts 2025-02-11 21:02:24 +01:00
search.go filter: allow workers to combine filter terms 2024-02-11 22:03:56 +01:00
send.go jmap: handle copy-to and :send -t 2024-12-21 17:02:31 +01:00
set.go tag: allow to toggle tags 2025-03-30 22:10:58 +02:00
threads.go jmap: explicitly fetch body structure subparts 2025-02-11 21:02:24 +01:00
worker.go treewide: replace uint32 uids with opaque strings 2024-08-28 12:06:01 +02:00