Skip to content

Commit 680b659

Browse files
committed
doc: warn about using util.inspect/util.format
Because of the potential performance bottlenecks that may be introduced by `util.inspect()` and `util.format()` in production hot path code. Based on real user feedback, it is not obvious that these are intended to be debugging tools.
1 parent 7a0f774 commit 680b659

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

doc/api/util.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ without any formatting.
250250
util.format('%% %s'); // '%% %s'
251251
```
252252

253+
Please note that `util.format()` is a synchronous method that is mainly
254+
intended as a debugging tool. Some input values can have a significant
255+
performance overhead that can block the event loop. Use this function
256+
with care and never in a hot code path.
257+
253258
## util.inherits(constructor, superConstructor)
254259
<!-- YAML
255260
added: v0.3.0
@@ -462,6 +467,11 @@ console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));
462467
// chunks.
463468
```
464469

470+
Please note that `util.inspect()` is a synchronous method that is mainly
471+
intended as a debugging tool. Some input values can have a significant
472+
performance overhead that can block the event loop. Use this function
473+
with care and never in a hot code path.
474+
465475
### Customizing `util.inspect` colors
466476

467477
<!-- type=misc -->

0 commit comments

Comments
 (0)