Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

value.trim() is not a function #2355

Closed
2 tasks done
r-flash opened this issue Feb 9, 2025 · 6 comments
Closed
2 tasks done

value.trim() is not a function #2355

r-flash opened this issue Feb 9, 2025 · 6 comments
Labels
bug Bug, will addressed with high priority

Comments

@r-flash
Copy link

r-flash commented Feb 9, 2025

Is there an existing issue for this?

  • I have searched the existing issues

music-metadata version

10.9.0

Current Behavior

I'm getting the following error for any MP3 file I try to run parseFile on. I have added some logs before the problematic line and turns out the type of value is actually Uint8Array, not string.

Sample MP3 file

file:///mnt/hdd/Projects/music-browser/dist/main.js:7230
        value = value.trim();
                      ^

TypeError: value.trim is not a function
    at Id3v1StringType.get (file:///mnt/hdd/Projects/music-browser/dist/main.js:7230:23)
    at Object.get (file:///mnt/hdd/Projects/music-browser/dist/main.js:7206:47)
    at FileTokenizer.readToken (file:///mnt/hdd/Projects/music-browser/dist/main.js:49:22)
    at async ID3v1Parser.parse (file:///mnt/hdd/Projects/music-browser/dist/main.js:7260:24)
    at async MpegParser.parseID3v2 (file:///mnt/hdd/Projects/music-browser/dist/AbstractID3Parser-Ce8k_va_.js:42:13)
    at async MpegParser.parse (file:///mnt/hdd/Projects/music-browser/dist/AbstractID3Parser-Ce8k_va_.js:19:13)
    at async ParserFactory.parse (file:///mnt/hdd/Projects/music-browser/dist/main.js:6729:9)
    at async parseFile (file:///mnt/hdd/Projects/music-browser/dist/main.js:7339:16)
    at async file:///mnt/hdd/Projects/music-browser/dist/main.js:7453:17

Expected Behavior

No error is thrown.

Attached audio sample?

  • I have provided sufficient information to reproduce the issue
@r-flash r-flash added the bug Bug, will addressed with high priority label Feb 9, 2025
@Borewit
Copy link
Owner

Borewit commented Feb 9, 2025

Hi @r-flash, that does not happen when I parse that file with [email protected].

Looking at your stack trace, you are using some post-processing of the code, maybe something odd is happening there.

Neither I can explain why you ending up value being an Uint8Array, and not a string:

value = value.trim();

@Borewit Borewit added the cannot reproduce The issue described cannot be reproduced label Feb 9, 2025
@Borewit
Copy link
Owner

Borewit commented Feb 9, 2025

Seems to work fine in the browser as well: https://audio-tag-analyzer.netlify.app/

Which JavaScript engine are you using?

@r-flash
Copy link
Author

r-flash commented Feb 9, 2025

Thanks for the quick response! I'm using Node v23.4.0. I'll try to investigate whether it has something to do with the usage of Rollup.

@Borewit
Copy link
Owner

Borewit commented Feb 9, 2025

It is related to Node v23.4.0, same issue on my end.

@Borewit Borewit removed the cannot reproduce The issue described cannot be reproduced label Feb 9, 2025
@Borewit
Copy link
Owner

Borewit commented Feb 9, 2025

Caused by issue: nodejs/node#56219

Related to sindresorhus/file-type#703

You can reproduce the issue like this:

it('Node Windows-1252 decode bug', () => {
  const textDecoder = new TextDecoder('Windows-1252');
  const binary = new Uint8Array([72, 101, 108, 108, 111]);
  const text = textDecoder.decode(binary);
  assert.strictEqual(typeof(text), 'string', 'expect a string');
});

Just update to a newer Node.js version, at least in v23.7.0 it seems resolved.

@Borewit Borewit closed this as completed Feb 9, 2025
@r-flash
Copy link
Author

r-flash commented Feb 9, 2025

I see, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, will addressed with high priority
Projects
None yet
Development

No branches or pull requests

2 participants