I try to implement a writable stream by inheriting from stream.Writable.
Invoking the callback passed to _write() with an error argument other than
null or undefined throws an TypeError exception. This there something wrong
with my code or is this a bug? I'm using node 0.10.x on Windows 7, x86.
var stream = require('stream'),
util = require("util");
function WriteStream(options) {
stream.Writable.call(this, options || {});
}
util.inherits(WriteStream, stream.Writable);
WriteStream.prototype._write = function(chunk, encoding, callback) {
if( callback ) {
callback('foo failed due bar');
// events.js:74
// throw TypeError('Uncaught, unspecified "error" event.');
}
};
process.stdin.pipe(new WriteStream());
This script fails when executed with some input from stdin:
node stream_test.js
events.js:74
throw TypeError('Uncaught, unspecified "error" event.');
^
TypeError: Uncaught, unspecified "error" event.
at TypeError ()
at WriteStream.EventEmitter.emit (events.js:74:15)
at WriteStream.onerror (_stream_readable.js:501:12)
at WriteStream.g (events.js:175:14)
at WriteStream.EventEmitter.emit (events.js:95:17)
at onwriteError (_stream_writable.js:223:10)
at onwrite (_stream_writable.js:241:5)
at WritableState.onwrite (_stream_writable.js:92:5)
at WriteStream._write (stream_test.js:13:9)
at doWrite (_stream_writable.js:211:10)
Any hits how to use the new WriteStream are appreciated. Thanks.
Cheers,
Mario
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.