fix: GetDataStream must extend Writable, not legacy Stream#19
Merged
msimerson merged 1 commit intoharaka:masterfrom Apr 8, 2026
Merged
fix: GetDataStream must extend Writable, not legacy Stream#19msimerson merged 1 commit intoharaka:masterfrom
msimerson merged 1 commit intoharaka:masterfrom
Conversation
Merged
Member
|
Today I remembered why I didn't update to the new Writable yet: node v20 is still under LTS until 2026-04-18. Yep, 10 more days before it goes EOL. This PR surfaces a race condition in node v20. Fortunately, the CI tests caught it (🎉 for good tests!) and I'll have it fixed soon. Fun fun. |
msimerson
added a commit
that referenced
this pull request
Apr 8, 2026
- fix: GetDataStream must extend Writable, not legacy Stream #19 - fix: limit header size to prevent memory exhaustion - fix: limit boundaries to prevent memory exhaustion - fix: sanitize the spool filename, prevent path traversal - fix: on Writable stream, set `autoClose: false` - `end` is a noop here, that's for fs.createReadableStream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #18
Summary
MessageStream.get_data(cb)hangs forever on spooled messages when the constructor is passed a non-emptyheadersarray. No'error'event fires; the only symptom is thatcbis never invoked, so any plugin reading the full body fromdata_posthits Haraka'splugin_timeoutand DENYSOFTs the message.Test coverage
Added one regression test:
get_data() returns full body for spooled messages with ctor headers. It:MessageStreamwithspool_after = 5 MBand a non-emptyheadersarray (mimicking Haraka transactions).get_data(cb)with a 3s timeout.Without this fix, the test times out after 3s with
get_data callback never fired. With the fix it completes in ~70 ms.Minimal repro
Without the fix: prints
❌ get_data never firedafter 5 s.With the fix: prints
✅ get_data fired, bytes=7600000after ~40 ms.