Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
Running into EMFILE error when using jsmediatags

I use jsmediatags to read a tags of a huge amount of files (>20.000). My code throws an EMFILE Error (ERROR fs Error: EMFILE: too many open files, open "path-to-file") because I exceed the maximum amount of open files. I cannot use anything like graceful-js, because fs is built into the module. So my question is: How do I avoid the EMFILE error?

I can think of 2 ways: Using something to read only batches of data at once or somehow replacing the fs dependency with graceful-js. It would be very helpful if somebody could point me in the right direction.

var addToDatabase = (files) => {
    for(let i=0;i<files.length;i++){
        if(files[i].endsWith(".mp3")){
            new jsmediatags.Reader(files[i])
            .setTagsToRead(["title", "track", "artist", "album", "year"])
            .read({
                onSuccess: function(tag) {
                    database.insert({path: files[i], title: tag.tags.title, track: tag.tags.track, artist: tag.tags.artist, album: tag.tags.album, year: tag.tags.year});
                },
                onError: function(error) {
                    console.log("ERROR", error.type, error.info, files[i]);
                }
            });
        }
    }
}

require('node-dir').files(_some_dir, function(err, files) {
    if (err) dispatch(rebuildDbRejected("ERROR while reading the database directory"));
    addToDatabase(files);
});
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I altered the NodeFileReader from jsmediatags and now it seems to work.

const fs = require('fs');
//added these lines
var gracefulFs = require('graceful-fs');
gracefulFs.gracefulify(fs);
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda