From 95a56b5a0b939ceb99fe9b80074778e8ef2e0765 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 23 Dec 2018 21:59:19 -0800 Subject: [PATCH] net: use decodeStrings public API for writable stream Instead of using an undocumented underscore-prefixed property to configure the writable stream instance to not encode strings as buffers, use the public API which is an options property passed to the constructor. Refs: https://github.com/nodejs/node/issues/445 PR-URL: https://github.com/nodejs/node/pull/25201 Reviewed-By: Ben Noordhuis Reviewed-By: Ruben Bridgewater Reviewed-By: Anto Aravinth Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen --- lib/net.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/net.js b/lib/net.js index 0577dd3c9fe0c7..7680c8860e1521 100644 --- a/lib/net.js +++ b/lib/net.js @@ -255,6 +255,8 @@ function Socket(options) { options.allowHalfOpen = true; // For backwards compat do not emit close on destroy. options.emitClose = false; + // Handle strings directly. + options.decodeStrings = false; stream.Duplex.call(this, options); // Default to *not* allowing half open sockets. @@ -308,9 +310,6 @@ function Socket(options) { this._pendingData = null; this._pendingEncoding = ''; - // handle strings directly - this._writableState.decodeStrings = false; - // If we have a handle, then start the flow of data into the // buffer. if not, then this will happen when we connect if (this._handle && options.readable !== false) {