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

216
Vistas
Execute js from string and get line number which failed

I am executing js which is stored as a string inside the db via:

let myScript = ` await Some()
lines()
of()
js()`

let result
try{
   result = await Object.getPrototypeOf(async function() {}).constructor(`return (async () => { ${myScript} })()`)()
} catch(e){
   result = 'Error occurred: '+e.message + ' stack: ' + e.stack
}

The problem is: The line numbers of e.stack are not correct. I think it's somehow also counting line numbers of the contextual code. For some js strings, I don't even get a stack.

Anyone knows what the problem is?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to add try-catch block in your string JS, I hope the answer to this Question will help you.

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