Skip to content

Commit

Permalink
stream: fix misleading error message
Browse files Browse the repository at this point in the history
The method to implement is `_write` not `_transform`.

PR-URL: #18604
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
lpinca authored and mcollina committed Feb 8, 2018
1 parent 87b9bce commit e9b5b4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

1 comment on commit e9b5b4f

@DavidMorton
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG. Thank you for this. Trying to figure out why the hell _transform is missing.... Updating would have given be a better error

Please sign in to comment.