Skip to content

Commit 9d39581

Browse files
committed
stream: add custom inspect to BufferList
Currently inspecting the BufferList can result a maximum call stack size error. Adding a individual inspect function prevents this. PR-URL: #17907 Refs: #12693 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 921fb84 commit 9d39581

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/internal/streams/BufferList.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const { Buffer } = require('buffer');
4+
const { inspect } = require('util');
45

56
function copyBuffer(src, target, offset) {
67
Buffer.prototype.copy.call(src, target, offset);
@@ -73,4 +74,9 @@ module.exports = class BufferList {
7374
}
7475
return ret;
7576
}
77+
78+
[inspect.custom]() {
79+
const obj = inspect({ length: this.length });
80+
return `${this.constructor.name} ${obj}`;
81+
}
7682
};

0 commit comments

Comments
 (0)