Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

208
Visualizações
Safe to remove async when no await's are used?

This may seam as a stupid question, but can I remove the async function below since there are no await's? It is a part of a large code base that is in production, so I am wondering if there could be some weird side effects if I remove async?

(async function(){
  'use strict';
  const {appLogger, monitorLogger} = require('./functions/logger');

...

  for (let i in p) {
    p[i].Filename = i;
    check(p[i]);
  }

...
    
  app.get('/example.json', (req, res) => {
    res.send(JSON.stringify(checkStates, null, 4));
  })

  app.listen(port, () => {
    appLogger.info(`Exposing http://localhost:${port}/example.json`);
  })

})();
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

My only thought would be that the await wraps any returned value (that isn't a promise) in a promise. However, this is a self-calling function and from what you've shown us there is nothing returned and nothing expecting a return. So unless there's other code you haven't shown, yes you should be fine.

about 4 years ago · Juan Pablo Isaza Relatório

0

Yes in this case you could remove async.

about 4 years ago · Juan Pablo Isaza Relatório

0

nope you dont need async if you're not awaiting for any promises.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda