-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Wrap all imported fs methods to set error stack trace limit to zero during their execution #40125
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
Wrap all imported fs methods to set error stack trace limit to zero during their execution #40125
Conversation
…uring their execution
@typescript-bot perf test this |
Heya @weswigham, I've started to run the perf test suite on this PR at 82dcd62. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the tarball bundle task on this PR at 82dcd62. You can monitor the build here. |
Hey @weswigham, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
const result = {} as any; | ||
for (const key in mod) { | ||
if (!(mod[key] instanceof Function)) continue; | ||
result[key] = (...args: any[]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth understanding whether an allocation for this array in each call is a potential problem.
@weswigham Here they are:Comparison Report - master..40125
System
Hosts
Scenarios
|
@@ -1135,7 +1155,7 @@ namespace ts { | |||
|
|||
function getNodeSystem(): System { | |||
const nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; | |||
const _fs: typeof import("fs") = require("fs"); | |||
const _fs: typeof import("fs") = wrapStacktraceReduction(require("fs")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we are doing this in sys for all functions, we should do it for all the other uses of fs too.. (nodeTypingInstaller, server etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, fair enough, I just didn't realize other things used fs
directly rather than sys
.
Is it really the case that we never want a stack from |
We never inspect the |
This doesn't seem like a great win for perf overall. We're introducing this overhead on every fs call, even though there's only a small number that regularly throw, and also introducing a duplicative |
This is just a followup to #40043 that blanket applies the idea to all
fs
methods we use (or will use in the future), rather than just one specificstatSync
usage.