-
Notifications
You must be signed in to change notification settings - Fork 146
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: wrong scope in captureMethod #1026
Conversation
using the captureMethod decorator the "this" is no longer the original obj so changing to the target fixes this
Hi @ratscrew thank you for taking the time to open a PR to this repo. Before investing time in reviewing the PR, could you please open an issue to report the bug and provide also reproduction steps / example of this bug? We'd like to understand more about what's happening. Then, after we have all agreed that it's in fact a bug, please review & edit the PR body and make sure to fill/check all the relevant sections. |
@dreamorosi thanks for your quick response i have added in the bug issue. thanks |
Thank you for opening the issue and providing more info, as I mentioned in the issue I was able to reproduce the bug. The fix that you are proposing seems like it would fix the issue. I was wondering if you could also please add a couple of tests to make sure it's the case and also to avoid future regressions. For the unit tests you can use this one as a reference: https://github.com/awslabs/aws-lambda-powertools-typescript/blob/main/packages/tracer/tests/unit/Tracer.test.ts#L892-L934 and add one in that same file & test group. Ideally we should have a passing test similar to the one in your issue. |
Thank you @ratscrew, we are really close, just some minor styling comments in one file - thanks for adding the unit test. Looking forward to merge this! |
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.
Thank you @ratscrew for the contribution and for taking the time to address the review comments, looks good to me.
I'm going to request the review of a second maintainer as we have a 2-approvals model before merging.
Note to the next maintainer: the checks are failing due to #991 but the tests, lint, etc. are OK
using the captureMethod decorator the "this" is no longer the original obj so changing to the target fixes this
Description of your changes
change the binding of the decorated method back to the target so the below code will work:
How to verify this change
Related issues, RFCs
#1028
PR status
Is this ready for review?: YES
Is it a breaking change?: NO
Checklist
Breaking change checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.