aws-powertools / powertools-lambda-typescript

Powertools is a developer toolkit to implement Serverless best practices and increase developer velocity.
https://docs.powertools.aws.dev/lambda/typescript/latest/
MIT No Attribution
1.58k stars 139 forks source link

Bug: cannot use captureAWSv3Client with the latest Tracer and AWS SDKs #1763

Closed danielsitnik closed 1 year ago

danielsitnik commented 1 year ago

Expected Behaviour

When using Tracer, I expect to be able to use the captureAWSv3Client function with any of the official SDKs.

Current Behaviour

When trying to use captureAWSv3Client with GlueClient (or any other client), TypeScript complains with the following error:

image

I'm using TypeScript version 4.9.5. Tested on DynamoDBClient and GlueClient, both at version 3.431.0

Code snippet

import {Tracer} from '@aws-lambda-powertools/tracer';
import {GlueClient} from '@aws-sdk/client-glue';

const tracer = new Tracer({serviceName: 'myService'});
tracer.captureAWSv3Client(new GlueClient({}));

Steps to Reproduce

Just use the provided code snippet.

Possible Solution

No response

Powertools for AWS Lambda (TypeScript) version

latest

AWS Lambda function runtime

16.x

Packaging format used

npm

Execution logs

No response

boring-cyborg[bot] commented 1 year ago

Thanks for opening your first issue here! We'll come back to you as soon as we can. In the meantime, check out the #typescript channel on our Powertools for AWS Lambda Discord: Invite link

dreamorosi commented 1 year ago

Hi @danielsitnik, thanks for taking the time to open this issue.

Based on the screenshot you have shared the type error appears to be coming from a file called dependency-container.d.ts at line 31, column 5. The project doesn't have any file with that name and you can verify this by searching the repo.

To try to isolate the issue, I have also tried to reproduce the error you describe using the versions you listed but was not able to. You haven't specified the version of Powertools Tracer you're using, so I have assumed the latest (1.14.0).

I have also created a sample repository with my setup, which you can find here: https://github.com/dreamorosi/repro-1763

After cloning that repository, please run npm ci to install the dependencies and then npm run build to compile it. In my case I was able to do so without error. Likewise, the IDE doesn't show any error.

If you can, please try to clone the repo I have shared and see if you see the error in that one as well.

danielsitnik commented 1 year ago

Ohhh my bad! I didn't notice it was coming from dependency-container.d.ts, this is from tsyringe.

I have been using it with the AWS SDKs for over a year without any problems. I guess the latest versions of the SDK changed something in the clients constructor that is causing this incompatibility now. 😞

Sorry, I'll take this issue over to the tsyringe team.

github-actions[bot] commented 1 year ago

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.