diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 6e0eaf45b5464d..7de77958d56b4c 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -179,6 +179,8 @@ if (typeof Symbol === 'function' && Symbol.hasInstance) { value: function(object) { if (realHasInstance.call(this, object)) return true; + if (this !== Writable) + return false; return object && object._writableState instanceof WritableState; } diff --git a/test/parallel/test-stream-inheritance.js b/test/parallel/test-stream-inheritance.js index 2d9a1e83ef7528..a687ea9da054c9 100644 --- a/test/parallel/test-stream-inheritance.js +++ b/test/parallel/test-stream-inheritance.js @@ -56,3 +56,8 @@ common.expectsError( message: 'undefined does not inherit from CustomWritable' } ); + +class OtherCustomWritable extends Writable {} + +assert(!(new OtherCustomWritable() instanceof CustomWritable)); +assert(!(new CustomWritable() instanceof OtherCustomWritable));