benrr101 / node-taglib-sharp

A node.js port of mono/taglib-sharp
GNU Lesser General Public License v2.1
42 stars 11 forks source link

Question - error setting title #76

Closed stuartambient closed 1 year ago

stuartambient commented 1 year ago

Got this message on a few .mp3's , 'Argument out of range length must be a safe, positive JS integer'. I assume it is related to a bad tag. I removed the tag completely and then ran it back again with node-taglib-sharp, no errors. Could it be related to:

"The Node.js 12 fs library only supports integer types for position arguments, which safely goes up to 2^52 - 1." I'm on Node 20.

This is my code

const tagger = (file, dir) => {
  const myFile = File.createFromPath(file);

    console.log(myFile.isPossiblyCorrupt); // returned false
    console.log(myFile.position); // returned 0
  try {
    if (!myFile.tag.title) {
      myFile.tag.title = path.basename(file);
    }

    myFile.save();
    myFile.dispose();
  } catch (err) {
    console.error(err.message, file);
  }
};
benrr101 commented 1 year ago

Hi, thanks for your question! I think your assessment is right that the tag is probably messed up in some way. Unfortunately, the isPossiblyCorrupt property is not used very consistently (as is the case in the original .net implementation) and probably won't indicate what's wrong with the tags. I'd be happy to do some more investigation, but I'll need at a minimum a stack trace and preferably a sample file with the issue.

As far as I can tell, the known issue you listed shouldn't be an issue in this case. This should only be an issue if you're working with a massive (like multiple terabyte) files. It's possible that the position is trying to be set to a huge value that wouldn't work here, but unless your file really is that huge, it's likely either a corrupt value or an incorrectly read value.

stuartambient commented 1 year ago

Well I haven't run into the issue again so far and since I didn't grab the stack trace I'll close this out. If it appears again I'll open another ticket.

Appreciate your quick response and the package in general. I get the unified methods mostly but am struggling with some of the advanced tagging,