- Haraka/transaction.js
- haraka/test-fixtures/transaction
new MessageStream(cfg, uuid, header_list)
Haraka Message Stream
Home Page: https://www.npmjs.com/package/haraka-message-stream
License: MIT License
[files]
in package.json. Delete .npmignore.node --test
in v18+When trying to pipe the connection.transaction.message_stream
to a target stream more than once, an error is thrown.
Example code in a queue plugin (without error handling for simplicity):
// in any plugin, possibly multiple times:
var txn = connection.transaction;
['/tmp/test-a', '/tmp/test-b', '/tmp/test-c'].forEach(file =>
{
txn.message_stream.pipe(fs.createWriteStream(file));
txn.message_stream.pause();
}
// finally, in the queue plugin:
txn.message_stream.resume();
This throws an error "Cannot pipe while currently piping". Browsing the code, it looks like this message_stream cannot be used in place of any regular readable stream?
The first idea for a workaround would be to listen to 'data', 'error', and 'end' events, instead of using the message_stream.pipe()
function. But that does not work out of the box either, I've tried multiple ways, but it only got me in a deeper mess.
Currently, I am using the following workaround instead (with error handling):
var txn = connection.transaction;
var multistream = txn.notes.message_stream || (txn.notes.message_stream = new stream.PassThrough());
['/tmp/test-a', '/tmp/test-b', '/tmp/test-c'].forEach(file =>
{
var target = fs.createWriteStream(file);
target.on('error', err => { throw err; });
multistream.on('error', err => target.destroy(err));
multistream.pipe(target);
});
await new Promise((resolve, reject) =>
{
multistream.on('error', reject);
multistream.on('finish', resolve);
txn.message_stream.on('error', err => multistream.destroy(err));
txn.message_stream.pipe(multistream);
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.