Skip to content

Add Large Mailbox Performance Tests for IMAP Client#20

Open
faizan-2022 wants to merge 5 commits intomainfrom
issues/new_features-testing
Open

Add Large Mailbox Performance Tests for IMAP Client#20
faizan-2022 wants to merge 5 commits intomainfrom
issues/new_features-testing

Conversation

@faizan-2022
Copy link
Contributor

@faizan-2022 faizan-2022 commented Jan 13, 2026

This PR introduces a set of integration tests to verify and optimize performance of the IMAP client when handling mailboxes containing 10,000+ messages. These tests ensure search speed, batch fetching, memory usage, pagination, and repeated operations meet acceptable performance standards.

1️⃣ Changes:

Added tests/unit/large-mailbox.test.ts to test:

Search performance with complex criteria (ALL, FROM, SINCE)

Efficient batch fetching of headers and full message bodies

UID-based pagination

Repeated fetches to check for memory leaks

Added error handling on IMAP client socket to prevent unhandled network errors (ECONNRESET)

Optional garbage collection (global.gc) used during large message fetches for memory management

Test execution gated with IMAP_PERF_TESTS=true to prevent running in CI

2️⃣ Criteria Verified:

✅ Search completes in <5s for 10k messages

✅ Memory usage stays bounded during large fetches

✅ UID-based pagination works correctly

✅ No memory leaks during repeated operations

3️⃣ How to Run Locally:

Run the following command in the terminal

IMAP_PERF_TESTS=true npm test tests/unit/large-mailbox.test.ts

4️⃣ Notes:

Requires a real IMAP server with a mailbox containing 10,000+ messages

Not intended for CI/CD environments


Important

Add performance tests for large mailboxes, Gmail label parsing, and MIME header handling in the IMAP client.

  • Performance Tests:
    • Added large-mailbox.test.ts to test IMAP client performance with mailboxes of 10,000+ messages.
    • Tests search speed, batch fetching, memory usage, pagination, and repeated operations.
    • Includes error handling for network errors and optional garbage collection.
    • Tests are gated with IMAP_PERF_TESTS=true to prevent CI execution.
  • Gmail Labels:
    • Added gmail-labels.test.ts to test parsing of Gmail system and custom labels.
    • Handles labels with spaces, nested labels, and special characters.
  • MIME Header Parsing:
    • Added header-parser.test.ts to test handling of special characters in MIME headers.
    • Tests Unicode, RFC 2047 encoded words, and edge cases like long subjects and malformed headers.

This description was created by Ellipsis for 3a09c14. You can customize this summary. It will automatically update as commits are pushed.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 3a09c14 in 56 seconds. Click for details.
  • Reviewed 387 lines of code in 4 files
  • Skipped 2 files when reviewing.
  • Skipped posting 5 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. package.json:117
  • Draft comment:
    Missing trailing newline at end-of-file for consistency.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50% None
2. tests/unit/gmail-labels.test.ts:101
  • Draft comment:
    Gmail labels tests are solid; consider adding additional edge cases for deeper nested labels or alternative delimiters.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
3. tests/unit/header-parser.test.ts:81
  • Draft comment:
    Header parser tests are comprehensive. Consider adding more variants of malformed encoded words to ensure robust fallback handling.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
4. tests/unit/large-mailbox.test.ts:82
  • Draft comment:
    The 5-second threshold for search performance may be too strict on slower environments; consider parameterizing or documenting this dependency.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
5. tests/unit/large-mailbox.test.ts:150
  • Draft comment:
    Repeated fetch tests use only 5 iterations; this may not capture subtle memory leaks. Consider implementing additional memory profiling.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None

Workflow ID: wflow_NMfvmTi8NBfmV8qs

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

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.

1 participant