Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

400
Vistas
TypeError: Converting circular structure to JSON - AWS Lambda

I know, this question has been asked a bunch of time. But I really don't know what's wrong with my code here. How can I fix this type error?

Where do I have a circular structure?

I'm running this code in a AWS Lambda function:

const addRanksToDB = async (tableName, stats) => {
  return Promise.all(Object.keys(stats).map(async (slug) => {
    const projectSlug = slug;
    const rankData = stats[slug];

    const messageBody = {
      rowId: projectSlug,
      table: tableName,
      identifier: 'project_slug',
      action: 'insert',
      payload: {
        project_slug: projectSlug,
        ...rankData,
        last_updated: knexClient.fn.now(),
      },
    };

    return sqs.sendMessage({
      MessageBody: JSON.stringify(messageBody),
      QueueUrl: 'https://sqs.eu-central-1.amazonaws.com/599632852002/handleDataInDBQueue',
    }).promise();
  }));
};

The rankData object looks like this:

{
  one_day_volume: 191,
  seven_day_volume: 162,
  thirty_day_volume: 179,
  total_volume: 156,
  num_owners: 4,
  average_price: 129,
  market_cap: 66,
  floor_price: 146
}

And this is the error I'm getting:

{
    "errorType": "TypeError",
    "errorMessage": "Converting circular structure to JSON\n    --> starting at object with constructor 'Timeout'\n    |     property '_idlePrev' -> object with constructor 'TimersList'\n    --- property '_idleNext' closes the circle",
    "trace": [
        "TypeError: Converting circular structure to JSON",
        "    --> starting at object with constructor 'Timeout'",
        "    |     property '_idlePrev' -> object with constructor 'TimersList'",
        "    --- property '_idleNext' closes the circle",
        "    at JSON.stringify (<anonymous>)",
        "    at /var/task/src/handlers/stats/webpack:/handlers/stats/rankProjectsByStatsCronjob.js:84:27",
        "    at Array.map (<anonymous>)",
        "    at v (/var/task/src/handlers/stats/webpack:/handlers/stats/rankProjectsByStatsCronjob.js:67:43)",
        "    at Runtime.R [as handler] (/var/task/src/handlers/stats/webpack:/handlers/stats/rankProjectsByStatsCronjob.js:188:23)",
        "    at processTicksAndRejections (internal/process/task_queues.js:95:5)"
    ]
}

The error is pointing to the line with MessageBody: JSON.stringify(messageBody),. How can I structure my sqs message so that I dont get this error?

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda