Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

243
Visualizações
Node S3Client Error - input.useDualstackEndpoint is not a function

I'm trying to get a list of files within an S3 folder in a lambda written in typescript. I've added the following dependencies to my package.json.

"@aws-sdk/client-s3": "^3.41.0",
"@aws-sdk/node-http-handler": "^3.40.0",

I then use the S3 client like this:

const client = new S3Client({
    maxAttempts: 3,
    retryMode: 'STANDARD',
    region: getAwsRegion(),
    requestHandler: new NodeHttpHandler({
      connectionTimeout: 3000, // Timeout requests after 3 seconds
      socketTimeout: 5000, // Close socket after 5 seconds
    }),
    credentials: args.credentials,
  });


  const listObjectsCommand = new ListObjectsCommand({
    Bucket: args.bucketName,
    Delimiter: '/',
    Prefix: pathToPartition,
  });
  const objects = await client.send(listObjectsCommand);

I've tried using ListObjectsV2Command as well, but it has the same error. The error is:

TypeError: input.useDualstackEndpoint is not a function\n at Object.getEndpointFromRegion (/var/task/node_modules/<my_module>/node_modules/@aws-sdk/config-resolver/dist-cjs/endpointsConfig/utils/getEndpointFromRegion.js:12:46)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at async Object.serializeAws_restXmlListObjectsCommand (/var/task/node_modules/<my_module>/node_modules/@aws-sdk/client-s3/dist/cjs/protocols/Aws_restXml.js:2386:68)\n at async /var/task/node_modules/<my_module>/node_modules/@aws-sdk/middleware-serde/dist-cjs/serializerMiddleware.js:5:21 .

Any idea what I may be doing wrong?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

This happened due to a mismatch is the aws-sdk version used in the package.json I had and the package.json of a dependency. Updating it to be the same version fixed this!

about 4 years ago · Juan Pablo Isaza Relatório

0

Here is a working minimal version of your function. Get this simple version working first and incrementally add complexity.

AWS_REGION is a lambda-provided env var. I defined the BUCKET env var. You can pass the bucket name with the event payload (or, to begin with, hard-code it to minimise sources of error).

import { S3Client, ListObjectsCommand} from '@aws-sdk/client-s3';

const client = new S3Client({ region: process.env.AWS_REGION });
const bucket = process.env.BUCKET;

export async function handler(): Promise<void> {
  const cmd = new ListObjectsCommand({
    Bucket: bucket
  });

  const objects = await client.send(cmd);

  console.log(objects)
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda