Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

93
Views
setTimeout pide un objeto y luego se ignora

Cuando configuro un nuevo setTimeout en el formulario:

 async function someFn(price){ ... await setTimeout( async function run(val) { await someFn(val); }, delay, price ); }

, me sale el error

 node:internal/errors:464 ErrorCaptureStackTrace(err); ^ TypeError [ERR_INVALID_ARG_TYPE]: The "options" argument must be of type object. Received type number (135.83422382) at new NodeError (node:internal/errors:371:5) at setTimeout (node:timers/promises:46:7)

así que lo cambio a

 async function someFn(price){ ... await setTimeout( async function run(val) { await someFn(val[0]); }, delay, [price] ); }

y el error desaparece de repente. El error tampoco aparece cuando el precio es una cadena, lo cual es extraño ya que la cadena también debería ser un tipo primitivo. Lo último más extraño es que después de esta corrección de matriz, la función dentro de setTimeout se ignora por completo cuando se ejecuta el código (un registro de consola antes y después de las impresiones).

Tenga en cuenta que este error solo aparece cuando llamo await someFn(x) desde dentro de un montón de .then(async (arg) => {<code>}) anidados blocks, but not when the await run(x) está en su propio. En general, este es el error más extraño que he visto, ¡y agradecería alguna orientación!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!