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

225
Views
¿Por qué este LockService no funciona como se esperaba al enviar un correo electrónico?

Estoy usando LockService cuando envío correos electrónicos, pero cuando varios usuarios lo ejecutan al mismo tiempo, arroja el error: Service invoked too many times...

Aquí hay un registro que muestra las fallas:

ingrese la descripción de la imagen aquí

 function sendEmail() { const ss = SpreadsheetApp.getActiveSpreadsheet(); var lock = LockService.getScriptLock(); try { lock.waitLock(3000); // wait 03 seconds for others' use of the code section and lock to stop and then proceed } catch (e) { Logger.log('Someone has just sent an Email. Try it again 3 seconds later.'); return HtmlService.createHtmlOutput("<b> Server Busy please try after some time <p>") // In case this a server side code called asynchronously you return a error code and display the appropriate message on the client side //return "Error: Server busy try again later... Sorry :(" } /* Gets certain data from current row. These are used as criteria */ GmailApp.sendEmail(email, "Text", name + " BODY.", { name: 'Diplay Custom Name as Sender' }); //Looks for a matching record in another sheet to mark its adjacent column as sent ("Yes") for (var n = 0; n < formRespValues.length; n++) { if (formRespValues[n][1] == testNo) { formRespSheet.getRange('M' + (2 + n)).setValue('Yes'); } } } SpreadsheetApp.flush(); // applies all pending spreadsheet changes lock.releaseLock(); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Como @Tanaike señaló en los comentarios , un breve período de tiempo dentro de waitLock(timeoutInMillis) o tryLock(timeoutInMillis) puede impedir que el servicio de bloqueo funcione como se espera.

Para garantizar el correcto funcionamiento, intente configurar un tiempo que sea mucho mayor que el tiempo de ejecución de su script. Si es menor que esto, la cerradura se "abrirá" prematuramente y provocará errores como los que se describen en la pregunta.

Documentación :
  • Servicio de bloqueo
  • bloqueo de clase
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!