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

277
Views
¿Cómo llamar a HttpException en setTimeout, cuando espero prometer mucho tiempo?

Recibo productos de diferentes servidores, quiero una excepción de devolución, cuando espero mucho tiempo. Creé setTimeout para esto, pero detuvo el servidor y no devolvió el error.

¿Como arreglarlo?

 const server = 23; const productsTimeout = setTimeout(() => { throw new HttpException('Problem', HttpStatus.INTERNAL_SERVER_ERROR) }, 3000); products = await new Promise((resolve, reject) => { this.socketClientCabinet.on('products_get', async ({ server, products }) => { if (server === serverID) { const { productsSymbols, } = this.productsTransform(products); clearTimeout(productsTimeout); resolve(productsSymbols); } }); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El usuario eliminó su respuesta, lo arreglé.

 let productsTimeout; const timeoutPromise = new Promise((res, rej) => { instrumentsTimeout = setTimeout(() => rej(new HttpException('problem', 500)), 1000, ) }) const productsPromise = new Promise((resolve, reject) => { this.socketClientCabinet.on('products_get', async ({ server, products }) => { if (server === serverID) { const { productsSymbols, } = this.productsTransform(products); clearTimeout(productsTimeout); resolve(productsSymbols); } }); }); const products = await Promise.race([ timeoutPromise, productsPromise ])

Eso es trabajo.

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