From 9d3958102ec28f2bb468b2c532b7b34cabd61f1b Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 16 Jan 2018 15:33:23 +0100 Subject: [PATCH] stream: add custom inspect to BufferList MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently inspecting the BufferList can result a maximum call stack size error. Adding a individual inspect function prevents this. PR-URL: https://github.com/nodejs/node/pull/17907 Refs: https://github.com/nodejs/node/issues/12693 Reviewed-By: James M Snell Reviewed-By: Matteo Collina Reviewed-By: Michaƫl Zasso --- lib/internal/streams/BufferList.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/internal/streams/BufferList.js b/lib/internal/streams/BufferList.js index 23d5a8a2db0eb7..c5a293b9ca0c16 100644 --- a/lib/internal/streams/BufferList.js +++ b/lib/internal/streams/BufferList.js @@ -1,6 +1,7 @@ 'use strict'; const { Buffer } = require('buffer'); +const { inspect } = require('util'); function copyBuffer(src, target, offset) { Buffer.prototype.copy.call(src, target, offset); @@ -73,4 +74,9 @@ module.exports = class BufferList { } return ret; } + + [inspect.custom]() { + const obj = inspect({ length: this.length }); + return `${this.constructor.name} ${obj}`; + } };