| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Codecov ReportAttention: Patch coverage is 95.91837% with 2 lines in your changes missing coverage. Please review.
@@ Coverage Diff @@
## main #54380 +/- ##
==========================================
- Coverage 87.61% 87.60% -0.01%
==========================================
Files 650 650
Lines 182829 182878 +49
Branches 35382 35390 +8
==========================================
+ Hits 160179 160210 +31
Misses 15931 15931
- Partials 6719 6737 +18
|
Sorry, something went wrong.
There was a problem hiding this comment.
Should we add an option to ignore node:internal?
Also, I think we should pretty print the callsite object, if we console.log it:
[
CallSite {},
CallSite {},
CallSite {},
CallSite {},
CallSite {},
CallSite {},
CallSite {},
CallSite {}
]If we JSON.stringify:
[{},{},{},{},{},{},{},{}]
And maybe we should add some snapshot tests, I know they could break if we change/add the methods that call them but usually they are great to track regressions, I know we have a couple snapshot tests like that in our codebase.
In general, looks great to me to have a utility function like this.
Sorry, something went wrong.
|
I'd not include an option to ignore it in this initial version - maybe a follow up pr once it's landed? It's not supposed to be printed via console.log because it's a CallSite representation. I will modify the API so it retrieves the stack trace from C++, and this should address this issue with the new object |
Sorry, something went wrong.
There was a problem hiding this comment.
I'm fine landing it with this js version, just include a benchmark and then we can evaluate if the new c++ version will be faster.
Also, having some snapshot tests will be good to see what will change when we land the c++ version.
Sorry, something went wrong.
|
C++ version will be landed on this PR. I didn't have time yet. |
Sorry, something went wrong.
|
Is the new API going to work for events like unhandledRejection? |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
Did you do a benchmark?
Sorry, something went wrong.
I did, but without having a fair comparison I don't know if it will mean much: From my local machine util/get-callsite.js n=1000000: 178,641.08162235853 I suspect the C++ implementation will be slower than the JS one for this particular scenario. We need to iterate over v8::StackTrace to create objects while the JS approach does not compute the values unless the function is called. e.g: .getFileName(). So the comparison will be unfair. But, remember that we've switched to C++ for a side-effect-less approach. I can optimize this code later. |
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
PR-URL: #54380 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Claudio Wunder <cwunder@gnome.org> Reviewed-By: James M Snell <jasnell@gmail.com>
Notable changes: lib: * (SEMVER-MINOR) add util.getCallSite() API (Rafael Gonzaga) #54380 repl: * doc-deprecate instantiating `node:repl` classes without `new` (Aviv Keller) #54842 src: * create handle scope in FastInternalModuleStat (Joyee Cheung) #54384 stream: * (SEMVER-MINOR) relocate the status checking code in the onwritecomplete (YoonSoo_Shin) #54032 tls: * (SEMVER-MINOR) add `allowPartialTrustChain` flag (Anna Henningsen) #54790 v8: * Revert "v8: enable maglev on supported architectures (Joyee Cheung) #54384 PR-URL: #54966
Notable changes: lib: * (SEMVER-MINOR) add util.getCallSite() API (Rafael Gonzaga) #54380 repl: * doc-deprecate instantiating `node:repl` classes without `new` (Aviv Keller) #54842 src: * create handle scope in FastInternalModuleStat (Joyee Cheung) #54384 stream: * (SEMVER-MINOR) relocate the status checking code in the onwritecomplete (YoonSoo_Shin) #54032 tls: * (SEMVER-MINOR) add `allowPartialTrustChain` flag (Anna Henningsen) #54790 v8: * Revert "v8: enable maglev on supported architectures (Joyee Cheung) #54384 PR-URL: #54966
Notable changes: lib: * (SEMVER-MINOR) add util.getCallSite() API (Rafael Gonzaga) #54380 repl: * doc-deprecate instantiating `node:repl` classes without `new` (Aviv Keller) #54842 src: * create handle scope in FastInternalModuleStat (Joyee Cheung) #54384 stream: * (SEMVER-MINOR) relocate the status checking code in the onwritecomplete (YoonSoo_Shin) #54032 tls: * (SEMVER-MINOR) add `allowPartialTrustChain` flag (Anna Henningsen) #54790 v8: * Revert "v8: enable maglev on supported architectures (Joyee Cheung) #54384 PR-URL: #54966
Notable changes: lib: * (SEMVER-MINOR) add util.getCallSite() API (Rafael Gonzaga) #54380 repl: * doc-deprecate instantiating `node:repl` classes without `new` (Aviv Keller) #54842 src: * create handle scope in FastInternalModuleStat (Joyee Cheung) #54384 stream: * (SEMVER-MINOR) relocate the status checking code in the onwritecomplete (YoonSoo_Shin) #54032 tls: * (SEMVER-MINOR) add `allowPartialTrustChain` flag (Anna Henningsen) #54790 v8: * Revert "v8: enable maglev on supported architectures (Joyee Cheung) #54384 PR-URL: #54966
| Back | FazBrowse Home | New Git URL |
This pull request introduces a new API method, util.getCallSite(), which provides a way to capture and inspect the call stack within a Node.js application. The method returns an array of CallSite objects, so developers can retrieve information about each function call in the stack trace.
Previously, they could reach the same behaviour by using Error.prepareStackTrace but, this API isn't that friendly IMO.