FactbirdHQ / amazon-dax-client

Amazon DAX Client for JavaScript
Apache License 2.0
0 stars 2 forks source link

Configurations for DaxClient are not passed to Document Client (cannot adjust the retry or timeout when using DAX) #10

Open jayfry1077 opened 3 months ago

jayfry1077 commented 3 months ago

Hoping I might get some help with this.

const dax = new AmazonDaxClient({endpoints: [process.env.DAX_ENDPOINT], region: env.AWS_REGION || 'us-east-1',  requestTimeout: 1000, maxRetryDelay: 1000, httpOptions: { timeout: 1000} });

export const ddbDaxClient = new DynamoDB.DocumentClient({
    service: dax as unknown as AWS.DynamoDB,
    maxRetryDelay: 1000,
    requestTimeout: 1000,
    httpOptions: { timeout: 1000}
})

I'm trying to set a custom timeouts which is supported by DocumentClient, however when I set it on the DaxClient it is not getting passed to the DocumentClient. Setting it on the DocumentClient is also not working.

All I want to do is make it so Dax does not retry a bunch of times, but overriding this internal retry logic does not seem possible. Any help I can get would be appreciated.

Here is the service.config that i can log. As you can see the timeouts are there, so are the retries, but its completely ignored.

  credentialProvider: CredentialProviderChain {
    providers: [
      [Function (anonymous)],
      [Function (anonymous)],
      [Function (anonymous)],
      [Function (anonymous)],
      [Function (anonymous)],
      [Function (anonymous)],
      [Function (anonymous)],
      [Function (anonymous)]
    ],
    resolveCallbacks: []
  },
  region: 'us-east-1',
  logger: null,
  apiVersions: {},
  apiVersion: null,
  endpoint: undefined,
  httpOptions: { timeout: 1000 },
  maxRetries: 1,
  maxRedirects: 0,
  paramValidation: true,
  sslEnabled: true,
  s3ForcePathStyle: false,
  s3BucketEndpoint: false,
  s3DisableBodySigning: true,
  s3UsEast1RegionalEndpoint: 'legacy',
  s3UseArnRegion: undefined,
  computeChecksums: true,
  convertResponseTypes: true,
  correctClockSkew: false,
  customUserAgent: null,
  dynamoDbCrc32: true,
  systemClockOffset: 0,
  signatureVersion: null,
  signatureCache: true,
  retryDelayOptions: {},
  useAccelerateEndpoint: false,
  clientSideMonitoring: false,
  endpointDiscoveryEnabled: undefined,
  endpointCacheSize: 1000,
  hostPrefixEnabled: true,
  stsRegionalEndpoints: 'legacy',
  useFipsEndpoint: false,
  useDualstackEndpoint: false,
  token: null,
  tokenProvider: TokenProviderChain {
    providers: [ [Function (anonymous)] ],
    resolveCallbacks: []
  },
  endpoints: [
    'dax-cluster-test.fwe2bv.dax-clusters.us-east-1.amazonaws.com:8111'
  ],
  requestTimeout: 1000,
  maxRetryDelay: 1000,
  constructor: [Function: Config] { __super__: [Function: Object] },
  getCredentials: [Function: getCredentials],
  getToken: [Function: getToken],
  update: [Function: update],
  loadFromPath: [Function: loadFromPath],
  clear: [Function: clear],
  set: [Function: set],
  keys: {
    credentials: [Function: credentials],
    credentialProvider: [Function: credentialProvider],
    region: [Function: region],
    logger: [Function: logger],
    apiVersions: {},
    apiVersion: null,
    endpoint: undefined,
    httpOptions: { timeout: 120000 },
    maxRetries: undefined,
    maxRedirects: 10,
    paramValidation: true,
    sslEnabled: true,
    s3ForcePathStyle: false,
    s3BucketEndpoint: false,
    s3DisableBodySigning: true,
    s3UsEast1RegionalEndpoint: 'legacy',
    s3UseArnRegion: undefined,
    computeChecksums: true,
    convertResponseTypes: true,
    correctClockSkew: false,
    customUserAgent: null,
    dynamoDbCrc32: true,
    systemClockOffset: 0,
    signatureVersion: null,
    signatureCache: true,
    retryDelayOptions: {},
    useAccelerateEndpoint: false,
    clientSideMonitoring: false,
    endpointDiscoveryEnabled: undefined,
    endpointCacheSize: 1000,
    hostPrefixEnabled: true,
    stsRegionalEndpoints: 'legacy',
    useFipsEndpoint: [Function: useFipsEndpoint],
    useDualstackEndpoint: [Function: useDualstackEndpoint],
    token: null,
    tokenProvider: [Function: tokenProvider]
  },
  extractCredentials: [Function: extractCredentials],
  setPromisesDependency: [Function: setPromisesDependency],
  getPromisesDependency: [Function: getPromisesDependency],
  params: {}
}
jayfry1077 commented 3 months ago

Update. It seems like after the first invocation of the lambda, the timeout is respected in following invocations, altho that might not be my configs doing