Uh oh!
There was an error while loading. Please reload this page.
lib: avoid mutating Error.stackTraceLimit when it is not writable - #38215
Conversation
nodejs-github-bot
commented
Apr 12, 2021
Uh oh!
There was an error while loading. Please reload this page.
bmeck
left a comment
There was a problem hiding this comment.
Realized this should be checking configurable, not frozen status to handle if someone does an Object.seal(Error), etc.
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/998/ Results look OK-ish: |
Error.stackTraceLimit when Error is frozenError.stackTraceLimit when it is not writableThere was a problem hiding this comment.
We could try to cache the value when the property is not configurable:
| returndesc.writable??typeofdesc.set==='function'; | |
| constreturnValue=desc.writable??typeofdesc.set==='function'; | |
| if(desc.configurable===false) | |
| module.exports.isErrorStackTraceLimitWritable=()=>returnValue; | |
| returnreturnValue; |
I think it makes the harder to read, and I think we should try to optimize for the most common case (which is when the property has configurable and writable set to true).
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Apr 13, 2021
nodejs-github-bot
commented
Apr 13, 2021
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/999/ EDIT: the results are not as good… I'd say the tradeoff is worth it, I'm open to suggestions to improve those figures. |
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Apr 14, 2021
aduh95
commented
Apr 14, 2021
I've added more tests. I think this is ready to land but I'd love to get a final approval to make sure I haven't forgotten anything :) |
nodejs-github-bot
commented
Apr 14, 2021
nodejs-github-bot
commented
Apr 14, 2021
PR-URL: nodejs#38215 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
aduh95
commented
Apr 14, 2021
Landed in 09c9e5d |
PR-URL: #38215 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This PR aims to avoid getting
Cannot assign to read only property 'stackTraceLimit' of function 'function Error() { [native code] }'errors thrown from core when Node.js is executed with the--frozen-intrinsicsflag.