When objects implement inspect
method but its not meant for inspection then problems might occur.
For example with rxjs
package:
> Rx = require("rxjs/Rx")
{ Subject: { [Function: Subject] create: [Function] },
Observable:
…
> s = new Rx.Subject()
RangeError: Maximum call stack size exceeded
at Subject.Observable (./node_modules/rxjs/Observable.js:21:24)
at new Subject (./node_modules/rxjs/Subject.js:17:16)
at Subject.lift (./node_modules/rxjs/Subject.js:28:23)
This is because Node's util.inspect
will try to call s.inspect
but that will recurse and throw an error.
Fix is to disable customInspect
option for util.inspect
as so:
let util = require("util");
let origInspect = util.inspect;
util.inspect = obj => origInspect(obj, { customInspect: false })
Now the same thing as above won't throw:
> s = new Rx.Subject()
Subject {
_isScalar: false,
destination: undefined,
…
The customInspect
option is documented here.
Opened RxJS issue #1387