如何正确closuresmeteorstream?

我正在使用一个stream,closures它后我有一个错误:

events.js:141 throw er; // Unhandled 'error' event ^ Error: write after end at writeAfterEnd (_stream_writable.js:166:12) ... 

stream是这样创build的:

 logStream = Object.create(null); function containerLogs(idContainer, from) { logStream[idContainer] = new stream.PassThrough(); 

然后我在网上find一个closures它的方法是:

 logStream[data.idContainer].end('!stop!'); 

但它会产生上面的错误,尽pipe它看起来像closuresstream。 我有点失落,如果有人能再次让我走上赛道,我会很感激

[编辑]这里是使用stream的function:

 function containerLogs(idContainer, from) { logStream[idContainer] = new stream.PassThrough(); logStream[idContainer].setEncoding('utf8'); logStream[idContainer].on('data', function(chunk){ console.log("you are receiving logs from: " + idContainer); try { Streamy.emit('resultLogs', { result: chunk.toString() },from); } catch (e) { console.log("error from on data"); } }); docker.getContainer(idContainer).logs({ follow: true, tail: 5, stdout: true, stderr: true }, function(err, stream){ if(err) { return logger.error(err.message); } docker.getContainer(idContainer).modem.demuxStream(stream, logStream[idContainer], logStream[idContainer]); }); }