Uh oh!
There was an error while loading. Please reload this page.
util: fix inspecting of proxy objects - #6465
Conversation
jasnell
commented
Apr 29, 2016
MylesBorins
commented
Apr 29, 2016
CI is green LGTM |
vkurchatkin
commented
Apr 29, 2016
-1, the whole point of proxies is being transparent |
addaleax
commented
Apr 29, 2016
That’s true for the programmatic use of proxies, but |
jasnell
commented
Apr 29, 2016
@addaleax +1 . Note that varm={};Object.defineProperty(m,'a',{enumerable: true,get: function(){console.log(this);return5;}});util.inspect(m);// Returns `{a: [Getter]}` |
jasnell
commented
Apr 29, 2016
(@thealphanerd ... what are you doing up at 2am reviewing code I wrote at 1am? Sleep my friend! Sleep!) |
There was a problem hiding this comment.
If you export this, it becomes public API, and should be documented.
There was a problem hiding this comment.
+1 ... Forgot to add the doc for it. Will add soon!
On Apr 29, 2016 6:29 AM, "Colin Ihrig" notifications@github.com wrote:
In lib/util.js
#6465 (comment):@@ -785,6 +792,10 @@ exports.isPrimitive = isPrimitive;
exports.isBuffer = Buffer.isBuffer;
+function isProxy(p) {
- return binding.isProxy(p);
+}
+exports.isProxy = isProxy;If you export this, it becomes public API, and should be documented.
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/nodejs/node/pull/6465/files/3d4ff4311a3cf1ff756413756ffc859a663aba99#r61577439
jasnell
commented
Apr 29, 2016
@cjihrig ... updated! PTAL |
jasnell
commented
Apr 29, 2016
New CI after update: https://ci.nodejs.org/job/node-test-pull-request/2432/ |
jasnell
commented
Apr 29, 2016
@cjihrig ... done! :-) @vkurchatkin ... +1 on it being semver-major (unfortunately). |
jasnell
commented
Apr 29, 2016
@vkurchatkin ... would this be a bit more palatable if there were an option on |
There was a problem hiding this comment.
This should probably be camelCase.
cjihrig
commented
Apr 29, 2016
LGTM pending CI, but it should sit for a couple days. |
vkurchatkin
commented
Apr 29, 2016
@jasnell after some thinking, I agree with your reasoning. Having an option is nice, but in practice no one uses them |
jasnell
commented
Apr 29, 2016
@cjihrig +1 for letting it sit a couple days. There's definitely no rush on it. |
In certain conditions, inspecting a Proxy object can lead to a max call stack error. Avoid that by detecting the Proxy object and outputting information about the Proxy object itself. Also adds util.isProxy() Fixes: nodejs#6464
jasnell
commented
Apr 29, 2016
Squashed, new CI: https://ci.nodejs.org/job/node-test-pull-request/2435/ |
jasnell
commented
Apr 29, 2016
CI is green. Will land on monday if there are no objections. /cc @nodejs/ctc |
Looks like this conflates two things:
Please do not land in this state. |
jasnell
commented
Apr 30, 2016
| function formatValue(ctx, value, recurseTimes) { | ||
| if (ctx.showProxy && | ||
| (typeof value === 'object' || typeof value === 'function')) { |
There was a problem hiding this comment.
You should check that typeof value === 'object' && value !== null, I think?
Style nit: can you drop the blank line?
jasnell
commented
May 1, 2016
@bnoordhuis ... updated |
| // for it to get proper formatting, and because | ||
| // the target and handle objects also might be | ||
| // proxies... it's unfortunate but necessary. | ||
| proxyCache.set(proxy, undefined); |
There was a problem hiding this comment.
I understand the logic but I don't think the 'necessary' is accurate; if you skipped adding proxy to the cache here, the algorithm would still work, only less efficiently. The next iteration would check the cache, miss, call .getProxyDetails() for the details array, and add the undefined return value to the cache a few lines below.
There was a problem hiding this comment.
Necessary in the sense of avoiding an extraneous call to getProxyDetails... Which I would consider to be a bug since the point is to only check when we don't know for sure. ;)
bnoordhuis
commented
May 2, 2016
LGTM |
Fishrock123
commented
May 2, 2016
CI after nits.. seems fine to me if others are happy with the details: https://ci.nodejs.org/job/node-test-pull-request/2459/ |
jasnell
commented
May 3, 2016
@thealphanerd and @cjihrig ... still LGTY? |
MylesBorins
commented
May 3, 2016
LGTM |
cjihrig
commented
May 3, 2016
Yes, LGTM |
In certain conditions, inspecting a Proxy object can lead to a max call stack error. Avoid that by detecting the Proxy object and outputting information about the Proxy object itself. Fixes: #6464 PR-URL: #6465 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
jasnell
commented
May 3, 2016
Landed in ba6196f. |
In certain conditions, inspecting a Proxy object can lead to a max call stack error. Avoid that by detecting the Proxy object and outputting information about the Proxy object itself. Fixes: #6464 PR-URL: #6465 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
In certain conditions, inspecting a Proxy object can lead to a max call stack error. Avoid that by detecting the Proxy object and outputting information about the Proxy object itself. Fixes: nodejs#6464 PR-URL: nodejs#6465 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* assert: `deep{Strict}Equal()` now works correctly with circular
references. (Rich Trott) #6432
* debugger: Arrays are now formatted correctly in the debugger repl.
(cjihrig) #6448
* deps: Upgrade OpenSSL sources to 1.0.2h (Shigeki Ohtsu)
#6550
* net: Introduced a `Socket#connecting` property. (Fedor Indutny)
#6404
- Previously this information was only available as the undocumented,
internal `_connecting` property.
* process: Introduced `process.cpuUsage()`. (Patrick Mueller)
#6157
* stream: `Writable#setDefaultEncoding()` now returns `this`.
(Alexander Makarenko) #5040
* util: Two new additions to `util.inspect()`:
- Added a `maxArrayLength` option to truncate the formatting of
Arrays. (James M Snell) #6334
- This is set to `100` by default.
- Added a `showProxy` option for formatting proxy intercepting
handlers. (James M Snell) #6465
- Inspecting proxies is non-trivial and as such this is off by
default.
PR-URL: #6557* assert: `deep{Strict}Equal()` now works correctly with circular
references. (Rich Trott) #6432
* debugger: Arrays are now formatted correctly in the debugger repl.
(cjihrig) #6448
* deps: Upgrade OpenSSL sources to 1.0.2h (Shigeki Ohtsu)
#6550
- Please see our blog post for more info on the security contents of this release:
- https://nodejs.org/en/blog/vulnerability/openssl-may-2016/
* net: Introduced a `Socket#connecting` property. (Fedor Indutny)
#6404
- Previously this information was only available as the undocumented,
internal `_connecting` property.
* process: Introduced `process.cpuUsage()`. (Patrick Mueller)
#6157
* stream: `Writable#setDefaultEncoding()` now returns `this`.
(Alexander Makarenko) #5040
* util: Two new additions to `util.inspect()`:
- Added a `maxArrayLength` option to truncate the formatting of
Arrays. (James M Snell) #6334
- This is set to `100` by default.
- Added a `showProxy` option for formatting proxy intercepting
handlers. (James M Snell) #6465
- Inspecting proxies is non-trivial and as such this is off by
default.
PR-URL: #6557* assert: `deep{Strict}Equal()` now works correctly with circular
references. (Rich Trott) #6432
* debugger: Arrays are now formatted correctly in the debugger repl.
(cjihrig) #6448
* deps: Upgrade OpenSSL sources to 1.0.2h (Shigeki Ohtsu)
#6550
- Please see our blog post for more info on the security contents of
this release:
- https://nodejs.org/en/blog/vulnerability/openssl-may-2016/
* net: Introduced a `Socket#connecting` property. (Fedor Indutny)
#6404
- Previously this information was only available as the undocumented,
internal `_connecting` property.
* process: Introduced `process.cpuUsage()`. (Patrick Mueller)
#6157
* stream: `Writable#setDefaultEncoding()` now returns `this`.
(Alexander Makarenko) #5040
* util: Two new additions to `util.inspect()`:
- Added a `maxArrayLength` option to truncate the formatting of
Arrays. (James M Snell) #6334
- This is set to `100` by default.
- Added a `showProxy` option for formatting proxy intercepting
handlers. (James M Snell) #6465
- Inspecting proxies is non-trivial and as such this is off by
default.
PR-URL: #6557
Checklist
Affected core subsystem(s)
util
Description of change
In certain conditions (see #6464), inspecting a Proxy object can lead to a max call stack error. Avoid that by detecting the Proxy object and outputting information about the Proxy object itself.
Also adds util.isProxy()
Fixes: #6464
/cc @bnoordhuis