-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
fix(base-driver): Update/simplify the logic for logger prefix #16683
Conversation
Can you explain what this avoids? |
This avoid possible memory leak in case the logger object itself is preserved somewhere. Without WeakRef the actual driver instance would be preserved with it as it is captured in the corresponding closure. |
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 we need WeakRef
here... please see comment.
I have updated the implementation, but now I have no idea about how to update unit tests after _log object gets reassigned in createSession. I also don't have a good idea on how to make prefix mutable on the logger itself |
@mykola-mokhnach Can I push to your branch? |
sure, not a problem at all |
Seems like I got some progress as of now. Please review once more @boneskull |
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.
This is good and was basically what I was suggesting, so thanks.
For a test I think all you really need to do is have something that compares this.log.prefix
before and after calling createSession()
, and again for deleteSession()
. We can assert the prefix looks a certain way, or we can just assert it's not the same.
You'd probably want to put that in the baseDriverUnitTests
function of test/basedriver/driver-tests.js
Proposed changes
This restores #16636 with some slight changes to make ts linter happy