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 MylesBorins committed Feb 21, 2018
1 parent 15db296 commit ba46103
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 @@ -551,7 +551,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

0 comments on commit ba46103

Please sign in to comment.