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.
  • Loading branch information
jasnell committed Dec 21, 2017
1 parent 7a0f774 commit 680b659
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 @@ -250,6 +250,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.inherits(constructor, superConstructor)
<!-- YAML
added: v0.3.0
Expand Down Expand Up @@ -462,6 +467,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 680b659

Please sign in to comment.