You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Server crashes when opening a library's Series page during a scan (Cannot set properties of null (setting 'media')) #5643
The server shut down while I opened a library's Series page. It happened while that library was being scanned (new books in series were being added). After that every client shows "Socket failed to connect" until the server is started again.
Crash log (metadata/logs/crash_logs.txt):
[Server] Unhandled rejection: TypeError: Cannot set properties of null (setting 'media')
at server/utils/queries/seriesFilters.js
at Array.map (<anonymous>)
at Object.getFilteredSeries (server/utils/queries/seriesFilters.js)
at async ApiRouter.getAllSeriesForLibrary (server/controllers/LibraryController.js)
What did you expect to happen?
The Series page loads (perhaps without the book that is still being added), and the server keeps running.
Steps to reproduce the issue
Add a folder with many books that belong to series to a library and start a scan.
While the scan is still adding books, open that library's Series page.
The server exits with the error above.
It seems to be a timing issue: I checked the database right after the crash and every bookSeries row pointed to a book that has a library item. So a book and its series link were saved a moment before the book's library item, and the Series query ran in between.
Cause
In getFilteredSeries (server/utils/queries/seriesFilters.js, v2.37.1, around line 208):
oldSeries.books=s.bookSeries.map((bs)=>{constlibraryItem=bs.book.libraryItemdeletebs.book.libraryItemlibraryItem.media=bs.book// libraryItem is null for a book whose library item doesn't exist (yet)...
Activity