Wellenline / auddly-server

Simple self-hosted music streaming server
https://auddly.app
MIT License
301 stars 12 forks source link

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined #14

Closed decaby7e closed 4 years ago

decaby7e commented 4 years ago

While using the supplied docker files, the following crash occurs when an MP3 is added to the music directory:

waveline-api | Starting new sync, this may take a while
waveline-api | (node:18) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
waveline-api |     at LibraryService.extractMetadata (/app/dist/Services/library.service.js:34:103)
waveline-api |     at processTicksAndRejections (internal/process/task_queues.js:97:5)
waveline-api |     at async LibraryService.sync (/app/dist/Services/library.service.js:91:9)
waveline-api | (node:18) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
waveline-api | (node:18) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The following is my project structure:

├── assets
│   └── placeholder.png
├── CHANGELOG.md
├── commitlint.config.js
├── data
│   └── mongo
│       ├── configdb
│       └── db
├── docker-compose.yaml
├── Dockerfile
├── music
│   └── KidCudi.mp3
├── package.json
├── package-lock.json
├── readme.md
├── src
│   ├── app.ts
│   ├── Http
│   │   ├── albums.ts
│   │   ├── artists.ts
│   │   ├── genres.ts
│   │   ├── middleware
│   │   │   └── global.ts
│   │   ├── playlists.ts
│   │   ├── search.ts
│   │   ├── system.ts
│   │   └── tracks.ts
│   ├── Models
│   │   ├── album.model.ts
│   │   ├── artist.model.ts
│   │   ├── genre.model.ts
│   │   ├── info.model.ts
│   │   ├── playlist.model.ts
│   │   └── track.model.ts
│   ├── Services
│   │   ├── library.service.ts
│   │   └── spotify.service.ts
│   └── utils
│       └── captialize.ts
├── test
│   └── test.ts
├── tsconfig.json
└── tslint.json

I suspect the issue could be related to the metadata of the mp3 by account of LibraryService.extractMetadata being in the error but this is just speculation.

Any help would be appreciated in debugging this issue :smile:

MihkelBaranov commented 4 years ago

Yeah it's most likely that something is missing from the metadata(maybe artist data?)

Server makes the assumption that all your music is correctly tagged and doesn't handle errors that well... It's something to improve on

decaby7e commented 4 years ago

Sounds about right; I found another song with metadata that I knew to be valid and that worked fine.

nebula-it commented 4 years ago

This is happening for all of my library. The songs are in .m4a format. They show up in app but /system/info is showing "albums":0,"artists":0,"

NoLooseEnds commented 4 years ago

When scanning my library I get the same error a few albums out, and then the scan halts. All songs identified up until the error works.

Maybe it's possible to keep scanning and output the files with errors to the log?

SeeSharpist commented 4 years ago

Confirmed it's the meta data. Once I added values for Title, Contributing artists, and Album to the files, everything worked. One bad file still seems to break the entire server though. Wouldn't connect through the web player or app if one file was missing any of those three.

Anyway to just use the file name as the title and default the Artist and Album to 'Unknown' or something similar if they're missing?

Was hoping to allow certain non-technical users to add their own music by making the file location a share, but if they can unknowingly break the server...