wildduck/test
titanism ea86c9fd46
fix(pop3): fix pipelining race condition causing mpop "invalid reply" errors (#950)
* fix(pop3): ensure pipelined RETR commands complete before processing next command

When POP3 clients use PIPELINING to send multiple RETR commands, the server
must ensure each message is fully transmitted (including the terminating dot)
before processing the next command. Previously, the server would call next()
when the source stream ended, but the DataStream transform (which adds the
terminating dot) might not have finished flushing to the socket yet.

This caused race conditions where the +OK response for the next RETR command
could be sent before the previous message's terminating dot, violating the
POP3 protocol and causing clients like mpop to report "invalid reply" errors.

The fix listens for the 'end' event on the DataStream (after it has written
the terminating dot) rather than the source stream, ensuring proper sequencing
of pipelined responses.

* test(pop3): add pipelining tests for RETR command race condition fix

Add comprehensive tests to verify that pipelined RETR commands are handled
correctly without interleaving responses. These tests simulate aggressive
POP3 client behavior (like mpop) that sends multiple RETR commands without
waiting for individual responses.

The tests verify:
- Multiple pipelined RETR commands complete in order
- Message terminating dot is sent before next +OK response
- The fix code exists in connection.js
- Rapid pipelining with 10 messages works correctly

* chore(test): add POP3 tests to grunt proto task

Update Gruntfile to include POP3 tests in the proto task, allowing protocol-
level tests (IMAP unit + POP3) to run without requiring MongoDB/Redis.

Changes:
- Add mochaTest:pop3 configuration for POP3 tests
- Add mochaTest:imap-unit for IMAP tests that don't require MongoDB
- Update proto task to run both imap-unit and pop3 tests

* fix(pop3): add defensive checks for stream.options.ttlcounter

Add defensive checks in RETR and TOP commands to handle streams
that don't have the options.ttlcounter property set. This fixes
a TypeError crash in Forward Email and other implementations that
don't set stream.options when returning from onFetchMessage.

The fix checks if stream?.options?.ttlcounter is a function before
calling it, and skips the ttlcounter call if not available.

Also adds:
- mpop pipelining tests for real-world client compatibility
- Tests for streams without options property
- Tests for streams with options but missing ttlcounter
- CI configuration to install mpop for testing
2026-01-08 09:36:27 +02:00
..
api fix(userHandler-asyncGetDeleted): ZMSA-52: user-handler create new asyncGetDeleted function to get deleted user by username, id, main address (#947) 2026-01-06 09:54:26 +02:00
fixtures
_globals-test.js fix: ZMSA-1: update release workflow, update deps, use updated deps, scope package (#887) 2025-10-17 12:04:48 +03:00
api-test.js fix: ZMSA-1: update release workflow, update deps, use updated deps, scope package (#887) 2025-10-17 12:04:48 +03:00
create-decipher-test.js fix(crypto.createDecipher): ZMSA-47: dkim legacy decipher fixes (#935) 2025-12-11 11:39:22 +02:00
filtering-test.js test-failing 2023-05-24 16:29:06 +03:00
filtering-tools-test.js fix(fulltext-filter): ZMS-257: Add boolean logic to fulltext filter (#863) 2025-09-15 11:56:07 +03:00
pop3-mpop-pipelining-test.js fix(pop3): fix pipelining race condition causing mpop "invalid reply" errors (#950) 2026-01-08 09:36:27 +02:00
pop3-onconnect-test.js fix(connection-management): implement connection management, POP3 timeout fixes, and comprehensive documentation (#835) 2025-07-23 10:46:13 +03:00
pop3-pipelining-test.js fix(pop3): fix pipelining race condition causing mpop "invalid reply" errors (#950) 2026-01-08 09:36:27 +02:00
pop3-timeout-test.js fix(connection-management): implement connection management, POP3 timeout fixes, and comprehensive documentation (#835) 2025-07-23 10:46:13 +03:00