aws / aws-xray-sdk-node

The official AWS X-Ray SDK for Node.js.
Apache License 2.0
266 stars 155 forks source link

Type incompatibility in @smithy/types between XRay and DynamoDBClient #665

Closed Jesusdiazrivero closed 1 month ago

Jesusdiazrivero commented 1 month ago

Hello,

Error It appears there is a type incompatibility between the XRay and AWS-SDK libraries. The following boilerplate code returns an error:

import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import AWSXRay from 'aws-xray-sdk-core';

const client: DynamoDBClient = AWSXRay.captureAWSv3Client(new DynamoDBClient({}));

There error is: Argument of type 'DynamoDBClient' is not assignable to parameter of type 'Client<any, any, any>'. Types of property 'middlewareStack' are incompatible. Property 'identifyOnResolve' is missing in type 'MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>' but required in type 'MiddlewareStack<any, any>'.ts(2345)

Investigation From what I've been able to assess, it seems the XRay library is using @smithy/types version ^3.3.0 (via @aws-sdk/types ^3.4.0) whereas the AWS SDK DynamoDB client library uses @smithy/types version ^1.1.0. The latter uses an additional generic parameter when declaring the Client class which seems to be the root cause of the issue.

I believe this issue is related to this one. I imagine there is a similar type incompatibility there. Not sure if this is a bug here and the version should be downgraded or if this should be raised to the AWS SDK team.

Package versions:

Jesusdiazrivero commented 1 month ago

Nevermind, upgraded to 3.9.0 after seeing the type changes present there