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

inconsistent inspect behaviors between host objects and decontextified objects #314

Open
shigma opened this issue Aug 7, 2020 · 6 comments
Assignees

Comments

@shigma
Copy link
Contributor

shigma commented Aug 7, 2020

const { VM } = require('vm2')

const vm = new VM()

console.log(new Date())) // Fri Aug 07 2020 23:39:04 GMT+0800 (中国标准时间)
console.log(vm.run('new Date()')) // Date {}
@XmiliaH
Copy link
Collaborator

XmiliaH commented Aug 7, 2020

This is a problem with node's inspect method. There is noting I can really do.

@shigma
Copy link
Contributor Author

shigma commented Aug 7, 2020

I think since we can attach toStringTag parameter to instance method, there is chance that we can attach a inspectCustom parameter to it as well (maybe through tough work though).

@XmiliaH
Copy link
Collaborator

XmiliaH commented Aug 7, 2020

That is certainly possible. However, custom inspect needs to be enabled and I am not sure if it is by default.

@shigma
Copy link
Contributor Author

shigma commented Aug 7, 2020

Can I have a try on this issue?

@XmiliaH
Copy link
Collaborator

XmiliaH commented Aug 7, 2020

If you want you can try it.

@shigma
Copy link
Contributor Author

shigma commented Aug 10, 2020

I just came up with another idea which may solve this issue: #315

@XmiliaH XmiliaH linked a pull request Aug 10, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants