Skip to content

feat: perform background fetch from all transports - #8592

Open
hpk42 wants to merge 1 commit into
mainfrom
hpk/background-fetch-all-transports
Open

feat: perform background fetch from all transports#8592
hpk42 wants to merge 1 commit into
mainfrom
hpk/background-fetch-all-transports

Conversation

@hpk42

@hpk42 hpk42 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

With I/O stopped, background_fetch() connected only to the transport of configured_addr (see #8572) and we now instead fan out to all transports once in a controlled loop without any notion of primary. This creates N IMAP connections with N=num(all_transports_of_all_profiles), instead of N=num(all_profiles). Whichever connection for each profile wins, will fetch and lock out the other connections, so that RAM usages through fetching actual IMAP messages should not change.

Known usages background_fetch in UIs:

With this PR, the overall behaviour should already improve, as we now use the first transport that connects fastest during background_fetch, instead of relying on a "primary" one only. However, current callers would still wait for all transports of all profiles to finish their single background fetch-round with the respective timeouts.

This can not be fixed in core, but UIs could drain events concurrently during background fetch, and cancel any fallback-handling if a real notification arrives. This should kind of guarantee UIs see the first message from whichever transport and whichever profile it arrives, and do not have to wait to the end of all background fetches (which might timeout, be killed by the OS etc.).

The PR also drops the N quota checks from background fetch: the check result is in-memory only, discarded when the iOS NSE exits, and the regular scheduler fetching refreshes quota every 60s anyway. Moreover, quota full are pretty rare since relays generally automatically stay under quota these days. This saves N concurrent round trips during background fetch and is simply not necessary.

Also adds previously missing online tests.

@hpk42
hpk42 force-pushed the hpk/background-fetch-all-transports branch 4 times, most recently from 50704f9 to 7720b34 Compare August 14, 2026 18:36
@Amzd

Amzd commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

wait for all profiles and transports to finish their fetch round

So every background fetch call will always go the full timeout if one of your relays on one of your profiles is offline? In that case android also needs to be updated as I think they also synchronously wait on this function (albeit only for 10 seconds)

@hpk42

hpk42 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

wait for all profiles and transports to finish their fetch round

So every background fetch call will always go the full timeout if one of your relays on one of your profiles is offline? In that case android also needs to be updated as I think they also synchronously wait on this function (albeit only for 10 seconds)

Offline relays will typically immediately fail, so there is no waiting for that. But if you implement concurrent event processing during background fetch, you shouldn't have to worry. The first working relay delivering a message will give you an incoming message, no matter what other connections hang or still need time.

With I/O stopped, `background_fetch()` connected only to the transport of `configured_addr`
and we now instead fan out to all transports in a controlled loop.

Also drop the quota check from this background fetch path:
its result is in-memory only, discarded when the iOS notification service exits,
and the regular scheduler fetching refreshes it every 60s anyway.
Moreover, quota errors/running full is pretty rare
since relays generally automatically stay under quota these days.
It's another round trip for each transport of each profile and simply not neccessary.

Also adds previosly missing online tests and adds `transport_id` to `ImapInboxIdle` Event
@hpk42
hpk42 force-pushed the hpk/background-fetch-all-transports branch from 7720b34 to 6c31d9e Compare August 15, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants