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

146
Vistas
InternalServerError: Converting circular structure to JSON

I got a problem with my app, anyone can help me ? Here is my code :

static me = async (req, res, next) => { 
        try {
            const returnDB = await user.me(req, res, next);
            res.status(200).json({
                status: true, 
                message: 'This user',
                returnDB
            })
        } catch (e) {
            next(createError(e.statusCode, e.message))
        }
    }

And here is my error :

InternalServerError: Converting circular structure to JSON
    --> starting at object with constructor 'Socket'
    |     property '_writableState' -> object with constructor 'WritableState'
    |     property 'afterWriteTickInfo' -> object with constructor 'Object'
    --- property 'stream' closes the circle
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

A circular reference ossurs when A refers to B and B refers to A (you can add more steps, if you like). That is no problem for JavaScript, but when you try to write such a setting down to JSON, you end up with an eternal loop.

In your case, the object returnDB refers to res

const returnDB = await user.me(req, res, next);

And res gets the JSON assigned that includes returnDB.

res.status(200).json({
    ...,
    returnDB
})

The error message tells you what attribute of which objects exactly refers to which other object.

Probably, you do not want to include the whole returnDB object in the response, but only some specific attribute of the object?

about 4 years ago · Juan Pablo Isaza Denunciar
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