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

Error.captureStackTrace is slow #13532

Closed
markjm opened this issue Jun 7, 2021 · 1 comment
Closed

Error.captureStackTrace is slow #13532

markjm opened this issue Jun 7, 2021 · 1 comment

Comments

@markjm
Copy link
Contributor

markjm commented Jun 7, 2021

Bug report

Related to #7378

What is the current behavior?
As discussed in #7378, TS type-only import/exports cause a large number of HarmonyLinking/WebpackError. In a sufficiently large project like ours, there are thousands of these errors. While the warnings existing don't cause much issue (since we just use ignoreWarnings regex to block them out), I noticed some interesting perf issues when creating these errors.

If the current behavior is a bug, please provide the steps to reproduce.
When creating these errors, Error.captureStackTrace is called. Based on our webpack perf CPU profiles, it seems that calling this function so many times really causes runtime cost to add up. In our traces, we weback serve dev command takes 9 seconds with this call disabled, down from 12 when enabled.

Since all these errors extend WebpackError which already extends Error, I think this captureStackTrace line isnt even necessary,since stack is automatically captured when new-ing up an error. There is a chance in some cases that we get a few extra stack lines within the error due to the frame hiding done when passing the constructor, but my just looking at the errors/warnings we were producing didn’t notice any difference.

image

What is the expected behavior?
Error.captureStackTrace doesn’t even need to be called due to Error inheritance, so just remove it

Other relevant information:
webpack version: 5.38.1
Node.js version: 16.2.0
Operating System: Windows
Additional tools: --

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants