• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

524
Views
¿Por qué recibo una advertencia para ejecutar fileHandle.close()?

Estoy ejecutando un programa nodeJS, que inicialmente lee una base de datos y luego escribe en ella, a través de varias iteraciones de un bucle for

 (async ()=>{ const db = JSON.parse(await fs.readFile(DB_URL)); // ... more code for(let i = 0; i < n /*n in the range of 10^3*/; i++){ // ... manipulate the db // ... more code const dir = './FolderName'; await fs.mkdir(dir, { recursive: true }); await Promise.all( arr.map(async (arrItem, index) => fs.writeFile(`${dir}/${index + 1}.png`, arrItem) ) ); await fs.writeFile( `${dir}/fileName.json`, JSON.stringify(db) ); } })()

Sin embargo, en momentos aleatorios, recibo este error.

 (node:36680) Warning: Closing file descriptor 39 on garbage collection (Use `node --trace-warnings ...` to show where the warning was created) internal/process/warning:50 (node:36680) [DEP0137] DeprecationWarning: Closing a FileHandle object on garbage collection is deprecated. Please close FileHandle objects explicitly using FileHandle.prototype.close(). In the future, an error will be thrown if a file descriptor is closed during garbage collection.

Leí deesta respuesta , que fileHandle.close() es necesario solo cuando abro un archivo usando fileHandle.open(). Entonces, ¿qué está fallando? ¿Por qué recibo este error?

about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error