fix: explicitly define property for entity relation as enumerable #9437
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of change
Change to makes properties for entity relation explicitly non-enumerable, which resolves a "rare" issue that leads to a memory leak.
In some environments it seems like an entity object was created with column values set to undefined, thus Object.defineProperty uses already defined value for enumerable - true. This leads to RawSqlResultsToEntityTransformer.transform() run-getters on relation fields (as they were enumerable) resolving the promises - running queries which eventually leads to the Free memory exhaustion on the machine :)
Closes: #6631
Pull-Request Checklist
master
branchnpm run format
to apply prettier formattingnpm run test
passes with this changeFixes #0000
Unfortunately while trying to find a way to replicate the issue in a couple of ways:
I wasn't able to replicate the same behavior in the test case, but while debugging I found exactly the same behavior in my code as other users reported in the issue.
Making
enumerable: false
explicitly stated shouldn't regress any code and seems like running tests locally confirmed that, howeversingle test did fail:UP: I see that on CI tests worked just fine