Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom inspection warning #21119

Closed
ivan-kleshnin opened this issue Jun 4, 2018 · 2 comments
Closed

Custom inspection warning #21119

ivan-kleshnin opened this issue Jun 4, 2018 · 2 comments

Comments

@ivan-kleshnin
Copy link

ivan-kleshnin commented Jun 4, 2018

Version: 10.3.0
Platform: OS-x
Subsystem: –

Something is broken about deprecation warning on .inspect. Honestly, I never heard of this method (Node's magic stuff?) But at this moment all libraries having objects with inspect method in their APIs are affected.

> {inspect: () => null}
null
> (node:1278) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated

One example of such library: https://github.com/origamitower/folktale

@jdalton
Copy link
Member

jdalton commented Jun 5, 2018

Hi @ivan-kleshnin!

This is because in Node 6.6.0 a symbol util.inspect.custom was added and the old behavior of using a method named inspect was deprecated. For more info on custom inspection see this. Eventually, the documentation deprecation became a runtime deprecation. You're seeing this in the REPL because under the hood the REPL uses util.inspect().

The deprecation and legacy functionality will be removed in Node 11 (#20722)

It does seem odd that the REPL use should trigger the deprecation warning since it's a side-effect of the REPL implementation. The simplest way to handle this in core would be with process.noDeprecation=true before the util.inspect() call and reset after.

For user-land a temporary workaround could be to add a non-function value of the util.inspect.custom symbol

Reflect.defineProperty(folktale, util.inspect.custom, {
  value: ""
})

@ivan-kleshnin
Copy link
Author

Ok, got it. Thank your for the explanation! Closing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants