diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index e1c912b333..af97fc2d81 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -284,9 +284,11 @@ function decodeChunk(state, chunk, encoding) { // If we return false, then we need a drain event, so set that flag. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { if (!isBuf) { - chunk = decodeChunk(state, chunk, encoding); - if (chunk instanceof Buffer) + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { encoding = 'buffer'; + chunk = newChunk; + } } var len = state.objectMode ? 1 : chunk.length;