Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
stream: fix misleading error message
The method to implement is `_write` not `_transform`.
  • Loading branch information
lpinca committed Feb 6, 2018
commit 117ed15052aafc5a5a6e23a37d025bd104624e0e
2 changes: 1 addition & 1 deletion lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ function clearBuffer(stream, state) {
}

Writable.prototype._write = function(chunk, encoding, cb) {
cb(new errors.Error('ERR_METHOD_NOT_IMPLEMENTED', '_transform'));
cb(new errors.Error('ERR_METHOD_NOT_IMPLEMENTED', '_write'));
};

Writable.prototype._writev = null;
Expand Down
12 changes: 11 additions & 1 deletion test/parallel/test-stream-writable-constructor-set-methods.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
require('../common');
const common = require('../common');
const assert = require('assert');

const Writable = require('stream').Writable;
Expand All @@ -26,6 +26,16 @@ w2.write(Buffer.from('blerg'));
w2.write(Buffer.from('blerg'));
w2.end();

const w3 = new Writable();

w3.on('error', common.expectsError({
type: Error,
code: 'ERR_METHOD_NOT_IMPLEMENTED',
message: 'The _write method is not implemented'
}));

w3.end(Buffer.from('blerg'));

process.on('exit', function() {
assert.strictEqual(w._write, _write);
assert(_writeCalled);
Expand Down