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

113
Views
Funciones de Firebase: ¿los errores de lanzamiento producen arranques en frío?

He leído aquí que los errores no controlados pueden causar arranques en frío. Estoy implementando una función activada, de la siguiente manera:

 exports.detectPostLanguage = functions .region("us-central1") .runWith({ memory: "2GB", timeoutSeconds: "540" }) .firestore.document("posts/{userId}/userPosts/{postId}") .onCreate(async (snap, context) => { // ... const language = await google.detectLanguage(post.text); // ... more stuff if no error with the async operation });

¿Necesito detectar los errores del método google.detectLanguage() para evitar arranques en frío?

En caso afirmativo, ¿qué debo hacer (A o B)?

A:

 const language = await google.detectLanguage(post.text) .catch(err => { functions.logger.error(err); throw err; // <---- Will still cause the cold start? });

B:

 try { var language = await google.detectLanguage(post.text) } catch(err) { functions.logger.error(err); return null; // <---- }

ACTUALIZAR

Basado en la solución de Frank:

 exports.detectPostLanguage = functions .region("us-central1") .runWith({ memory: "2GB", timeoutSeconds: "540" }) .firestore.document("posts/{userId}/userPosts/{postId}") .onCreate(async (snap, context) => { try { // ... const language = await google.detectLanguage(post.text); // ... more stuff if no error with the async operation } catch(err) { return Promise.reject(err); } return null; // or return Promise.resolve(); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si se escapa alguna excepción del cuerpo de Cloud Function, el tiempo de ejecución asume que el contenedor se encuentra en un estado inestable y ya no lo programará para manejar eventos.

Para evitar esto, asegúrese de que ninguna excepción se escape de su código. Puede devolver ningún valor o una promesa que indique cuándo se realizan las llamadas asincrónicas en su código.

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!