Skip to content
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

DynamoDBDocumentClients override other DynamoDBDocumentClients' marshalling options #6545

Closed
3 of 4 tasks
misterjoshua opened this issue Oct 4, 2024 · 2 comments
Closed
3 of 4 tasks
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue queued This issues is on the AWS team's backlog

Comments

@misterjoshua
Copy link

misterjoshua commented Oct 4, 2024

Checkboxes for prior research

Describe the bug

When you're sharing one DynamoDBClient between multiple DynamoDBDocumentClients, the marshalling options from the most recently created document client overwrites all the other document clients' marshalling options.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/lib-dynamodb@3.664.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

Node 20.13.1

Reproduction Steps

test('error', async () => {
  const sharedClient = new DynamoDBClient();

  const doc1 = DynamoDBDocumentClient.from(sharedClient, {
    marshallOptions: {
      convertEmptyValues: true,
      removeUndefinedValues: true,
    },
  });

  const doc2 = DynamoDBDocumentClient.from(sharedClient, {
    marshallOptions: {
      convertEmptyValues: false,
      removeUndefinedValues: false,
    },
  });

  expect(doc1.config.translateConfig?.marshallOptions?.removeUndefinedValues).toBe(true);
  expect(doc1.config.translateConfig?.marshallOptions?.convertEmptyValues).toBe(true);
});

Observed Behavior

The first document client's marshallOptions were overwritten by the second's marshallOptions.

Expected Behavior

Each document client's options should be distinct and should not affect each other even if they're sharing a DynamoDBClient.

Possible Solution

this.config = client.config;
this.config.translateConfig = translateConfig;

DynamoDBDocumentClient is sharing and mutating the underlying DynamoDBClient's config object when it should be keeping a private copy of the translate config.

Additional Information/Context

No response

@misterjoshua misterjoshua added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 4, 2024
@kuhe kuhe added p2 This is a standard priority issue queued This issues is on the AWS team's backlog and removed needs-triage This issue or PR still needs to be triaged. labels Oct 4, 2024
@kuhe
Copy link
Contributor

kuhe commented Nov 1, 2024

We don't plan to change this behavior currently. Please create two DynamoDB client instances.

If you want them to share credentials and socket pools, refer to the documentation here: https://github.com/aws/aws-sdk-js-v3/blob/main/supplemental-docs/performance/parallel-workloads-node-js.md#client-instances.

Excerpt (replace S3 with DynamoDB):

// example: credential and socket pool sharing from user instantiated objects.
import { S3 } from "@aws-sdk/client-s3";
import { fromNodeProviderChain } from "@aws-sdk/credential-providers";
import { NodeHttpHandler } from "@smithy/node-http-handler";

const credentials = fromNodeProviderChain();
const requestHandler = new NodeHttpHandler({
  httpsAgent: {
    maxSockets: 100,
  },
});

const s3_east = new S3({ region: "us-east-1", credentials, requestHandler });
const s3_west = new S3({ region: "us-west-2", credentials, requestHandler });

@misterjoshua misterjoshua closed this as not planned Won't fix, can't repro, duplicate, stale Nov 9, 2024
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. p2 This is a standard priority issue queued This issues is on the AWS team's backlog
Projects
None yet
Development

No branches or pull requests

3 participants