Skip to content

Commit

Permalink
stream: add custom inspect to BufferList
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
BridgeAR committed Jan 16, 2018
1 parent 921fb84 commit 9d39581
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/internal/streams/BufferList.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -73,4 +74,9 @@ module.exports = class BufferList {
}
return ret;
}

[inspect.custom]() {
const obj = inspect({ length: this.length });
return `${this.constructor.name} ${obj}`;
}
};

0 comments on commit 9d39581

Please sign in to comment.