Skip to content

Conversation

dreamorosi
Copy link
Contributor

Summary

Changes

Please provide a summary of what's being changed

This PR updates the internal implementation of the captureLambdaHandler class method decorator in Tracer so that it forwards the args of the decorated handler method as they appear at runtime rather than destructuring them and forcing the third parameter (callback) to be undefined.

Its presence, even when not defined, caused the runtime to interpret the handler as using callback style, which in turn caused deprecation warnings to show up.

Please add the issue number below, if no issue is present the PR might get blocked and not be reviewed

Issue number: closes #4306


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@dreamorosi dreamorosi self-assigned this Aug 12, 2025
@pull-request-size pull-request-size bot added the size/S PR between 10-29 LOC label Aug 12, 2025
Copy link

boring-cyborg bot commented Aug 12, 2025

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #typescript channel on our Powertools for AWS Lambda Discord: Invite link

@boring-cyborg boring-cyborg bot added the tracer This item relates to the Tracer Utility label Aug 12, 2025
Copy link

@dreamorosi
Copy link
Contributor Author

@sdangol can you please review the implementation of all the other decorators in the codebase and see if they need the same change? If needed, you can use the triaging runbook and deploy a functions to verify whether decorating causes a warning:

import type { Callback } from 'aws-lambda';

class Handler {
  // insert decorator here - should not cause a warning
  handler(event: unknown, context: unknown) {
    return {
      statusCode: 200,
      body: JSON.stringify({ message: 'Hello from Lambda!' }),
    };
  }
}

const lambda = new Handler();
export const handler = lambda.handler.bind(lambda);

If you find any, can you open a group issue to apply the same fix and link it back in #4312?

@dreamorosi dreamorosi merged commit 7bd81ae into main Aug 12, 2025
40 checks passed
@dreamorosi dreamorosi deleted the fix/tracer_args branch August 12, 2025 14:55
Copy link

boring-cyborg bot commented Aug 12, 2025

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S PR between 10-29 LOC tracer This item relates to the Tracer Utility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Warning callback-based function handlers caused by @tracer.captureLambdaHandler()
2 participants