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

209
Views
establezca el intervalo en el bloque de prueba pero borre si detecta una excepción

Tengo un código que llama a un setInterval en el bloque de prueba y borro el intervalo al final del código, pero si mi código detecta una excepción, la función setInterval sigue ejecutándose para siempre. ¿Cómo puedo borrar esto si el sqsInterval que creé en el bloque de prueba no existe en la captura?

 const createInterval = (message, queueUrl) => { let timeout = parseInt(process.env.QUEUE_VISIBILITY_TIMEOUT, 10); const interval = setInterval(() => { timeout += parseInt(process.env.VISIBILITY_TIMEOUT_INCREMENT, 10); if (timeout > 43200) { return; } const params = { QueueUrl: queueUrl, ReceiptHandle: message.ReceiptHandle, VisibilityTimeout: timeout, }; sqs.changeMessageVisibility(params, (err, data) => { if (err) logger.error(err, err.stack); else logger.info(JSON.stringify(data)); }); }, parseInt(process.env.TIMER_INTERVAL, 10)); return interval; }; try { // Starting time for complete clip project const queueUrl = process.env.AWS_SQS_VIDEO_CLIPS_QUEUE_URL; const sqsInterval = createInterval(message, queueUrl); await sleep(30000); clearInterval(sqsInterval); logger.info(`Finished processing message - [MessageID: ${message.MessageId}], [ReceiptHandle: ${message.ReceiptHandle}] [MD5OfBody]: ${message.MD5OfBody} [noteId=${noteId}]`); } catch (error) { clearInterval(sqsInterval);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const sqsInterval tiene un alcance dentro de try{ } . Declararlo afuera con let

 let sqsInterval; try { const queueUrl = process.env.AWS_SQS_VIDEO_CLIPS_QUEUE_URL; sqsInterval = createInterval(message, queueUrl); await sleep(30000); clearInterval(sqsInterval); logger.info(`Finished processing message - [MessageID: ${message.MessageId}], [ReceiptHandle: ${message.ReceiptHandle}] [MD5OfBody]: ${message.MD5OfBody} [noteId=${noteId}]`); } catch (error) { clearInterval(sqsInterval); }
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!