-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Memory leak fix: release console output reference after printed to stdout. #8233
Memory leak fix: release console output reference after printed to stdout. #8233
Conversation
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.
Nice :)
), | ||
); | ||
result.console = undefined; |
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.
I don't think the reporter should be responsible for mutating the testresult object. The memory consumption would be reintroduced with custom reporters. Can we move this to the runner or jest-core instead?
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.
Great feedback, moved to jest-core
. To be honest, I just blindly followed the pattern of how coverage
was previously released without thinking about it too carefully. Thanks for your review.
Codecov Report
@@ Coverage Diff @@
## master #8233 +/- ##
=======================================
Coverage 62.33% 62.33%
=======================================
Files 265 265
Lines 10553 10553
Branches 2565 2567 +2
=======================================
Hits 6578 6578
Misses 3387 3387
Partials 588 588
Continue to review full report at Codecov.
|
This fix broke compatibility with ability to print console logs in the reports (like jest-html-reporter). The feature to incorporate certain logs from the test execution into the report is quite useful. Reference issue is #Hargne/jest-html-reporter#61 Rather than completely disabling it, it would be great to see a parameter / hook, so developers have ability to define, if they want to keep logs, throw them right away, or process in a certain way (e.g. persist in a report file, or shorten, to avoid huge memory consumption in case tests generate huge amount of logs). Or at least document that capability (as it can be currently supported by using custom reporter). |
We can just move the cleanup to a later part of the lifecycle if needed - I think that's cleaner than more config. Mind opening up a separate issue with a quick reproduction? |
It definitely should not be available in The reporter should be able to get at the console logs as each test completes individually and store them for later access if needed. If this doesn't work for some reason file an issue and I'm willing to fix that. |
@SimenB, @scotthovestadt It make sense, reporter shall hook into For a quick and dirty WA to make current reporters compatible with a newer jest version (again reference to jest-html-reporter) I'm just "restoring" the value for |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
The reference to the console output is printed to
stdout
when the test completes and not used afterwards. Unfortunately, it's currently preserved, never being released. It's not used after that point and can be garbage collected.I also standardized the "no buffer" output to
undefined
, when it previously could have been an empty array ornull
.Test plan