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

123
Views
await escribir en el archivo solo se llama al azar

Estoy usando octokitjs para obtener el sha de un archivo y luego escribir en el archivo. Tengo alrededor de 8 archivos en ese repositorio de Github. Necesito escribir en los archivos uno por uno. Aquí está mi código:

 async function separateCars() { await rss[0].originalItems.forEach(item => { const title = item.title //if else condition to separate car by its type }) } const commitCars = async(car) => { const newCar = transformRssToMD(car.items); async function getSHA(path) { try { const result = await octokit.repos.getContent({ owner: "bob", repo: "car-repo", path: path }); const sha = result?.data?.sha; return sha; } catch (error) { console.log(error); } } function getPath(car) { if(car.title === 'volvo'){ return `volvo.md`; } else if(car.title === 'audi'){ return `audi.md` } else if(car.title === 'benz'){ return `benz.md` } else if(car.title === 'bmw'){ return `bmw.md` } else if(car.title === 'tesla'){ return `tesla.md` } else if(car.title === 'honda'){ return `honda.md` } else if(car.title === 'tata'){ return `tata.md` } else if(car.title === 'suzuki'){ return `suzuki.md` } } async function commitToGH(car){ const path = getPath(car); const sha = await getSHA(path); try { const result = await octokit.repos.createOrUpdateFileContents({ owner: "bob", repo: "car-repo", path: path, message: `latest cars updated`, content: Base64.encode(`${newCars}`), branch: 'main', sha, }); console.log("result", result); return result?.status || 500; } catch (error) { console.log(error); } } const results = await commitToGH(car); } async function callCommits(){ await separateCars().then(()=> { commitCars(vovlo); commitCars(tesla); commitCars(bmw); commitCars(tata); commitCars(suzuki); commitCars(audi); commitCars(honda); commitCars(benz); }); } callCommits(); }

Aquí se llama a getPath 8 veces como se esperaba. Pero getsha solo se llama al azar como 2 veces en ejecución o 4 veces en una ejecución. Y el createorUpdateFileContents también solo se llama al azar. Estoy golpeado con este problema desde hace 2 días. ¿Qué estoy haciendo mal? ¿algún problema con async-await?

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!