Skip to content

Commit

Permalink
doc: warn about using util.inspect/util.format
Browse files Browse the repository at this point in the history
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.

PR-URL: #17791
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
jasnell authored and targos committed Mar 24, 2018
1 parent 5f1a01d commit 742b304
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ without any formatting.
util.format('%% %s'); // '%% %s'
```

Please note that `util.format()` is a synchronous method that is mainly
intended as a debugging tool. Some input values can have a significant
performance overhead that can block the event loop. Use this function
with care and never in a hot code path.

## util.getSystemErrorName(err)
<!-- YAML
added: v9.7.0
Expand Down Expand Up @@ -437,6 +442,11 @@ console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));
// chunks.
```

Please note that `util.inspect()` is a synchronous method that is mainly
intended as a debugging tool. Some input values can have a significant
performance overhead that can block the event loop. Use this function
with care and never in a hot code path.

### Customizing `util.inspect` colors

<!-- type=misc -->
Expand Down

0 comments on commit 742b304

Please sign in to comment.