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

235
Views
¿Cómo hacer que NodeJS espere hasta que se resuelva una promesa dentro de una suscripción?

Tengo el siguiente código:

 import Web3 from 'web3'; function waitForFunds() { let web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545')); return new Promise((resolve, reject) => { web3.eth.subscribe('pendingTransactions').on("data", resolve); }); }; (async function () { await waitForFunds(); console.log('Waiting'); })();

Esperaría que nodeJS espere hasta que se resuelva la promesa devuelta por waitForFunds() , pero en cambio, NodeJS simplemente sale de inmediato y no espera que la suscripción resuelva la promesa al recibir los datos. La consola nunca registra "Esperando". ¿Estoy haciendo algo mal?

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