Cannot call captureAWSv3Client for s3 client
tmokmss opened this issue · comments
Hi, I get a type error from the following code:
import * as AWSXRay from 'aws-xray-sdk-core';
import { S3Client } from '@aws-sdk/client-s3';
const s3Client = AWSXRay.captureAWSv3Client(new S3Client({}));
the error I get:
Argument of type 'S3Client' is not assignable to parameter of type 'Client<any, any, any>'.
The types of 'middlewareStack.concat' are incompatible between these types.
Type '<InputType extends ServiceInputTypes, OutputType extends ServiceOutputTypes>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<...>' is not assignable to type '<InputType extends any, OutputType extends any>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<InputType, OutputType>'.
Types of parameters 'from' and 'from' are incompatible.
Property 'identify' is missing in type 'MiddlewareStack<InputType, OutputType>' but required in type 'MiddlewareStack<InputType, ServiceOutputTypes>'.ts(2345)
middleware.d.ts(307, 5): 'identify' is declared here.
Is there any workaround? Is v3 s3 client is even supported? Thanks!
Also getting this for DynamoDBClient:
import { captureAWSv3Client } from 'aws-xray-sdk-core';
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
captureAWSv3Client(new DynamoDBClient({
region,
endpoint,
}));
error
Conversion of type 'Client<any, any, any>' to type 'DynamoDBClient' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Types of property 'middlewareStack' are incompatible.
Property 'identify' is missing in type 'MiddlewareStack<any, any>' but required in type 'MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>'.ts(2352)
Thanks for reporting this. Did this issue only start happening with a recent version of the AWS SDK v3, or is this reproducible in all versions? Please follow the workaround documented here, casting the client as any
: https://github.com/aws/aws-xray-sdk-node/tree/master/packages/core#capture-outgoing-aws-requests-on-a-single-client
@willarmiros
I confirmed as any
works well, thanks!
const s3Client = AWSXRay.captureAWSv3Client(new S3Client({}) as any);
I'm not sure if it is a new issue since it is the first time for me to use xray with aws sdk v3. FYI I'm using "@aws-sdk/client-s3": "^3.180.0", "aws-xray-sdk": "^3.3.7"
.
I believe this issue should be reopened. Casting to any isn't really a good workaround.
I have the same issue - checked on 3.264.0 for @aws-sdk/client-dynamodb and all available versions of aws-xray-sdk-core.
Please reopen