Skip to content

BUG: Fetcher chunkSize over-fetches when caller asks for fewer than 50 #1106

@andrinoff

Description

@andrinoff

Describe the bug

fetcher/fetcher.go:415-418:

chunkSize := limit
if chunkSize < 50 {
    chunkSize = 50
}

If the caller requests limit=5, we still fetch 50 from IMAP per loop, filter, sort, append, and trim to 5. That's a 10× waste of bandwidth and IMAP server load on every paginated tail.

Expected behavior

Use limit directly; only inflate if the filter is known to drop more than half the messages (and bias the inflation to the historical hit rate).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    In review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions