[Bug]: Library scan failing #1889

Closed
opened 2026-04-25 00:00:59 +02:00 by adam · 6 comments
Owner

Originally created by @decoherencer on GitHub (Apr 16, 2024).

Describe the issue

While trying to click on "scan" button in libraries, the new books are not being scanned, the server disconnects for a second and reconnects and is stuck in scanning loop.

the log:

[Server] Unhandled rejection: ReferenceError: structuredClone is not defined, promise: Promise { <rejected> ReferenceError: structuredClone is not defined at LibraryItemScanData.checkLibraryItemData (/snapshot/audiobookshelf-git/server/scanner/LibraryItemScanData.js) at LibraryScanner.scanLibrary (/snapshot/audiobookshelf-git/server/scanner/LibraryScanner.js) at async LibraryScanner.scan (/snapshot/audiobookshelf-git/server/scanner/LibraryScanner.js) at async ApiRouter.scan (/snapshot/audiobookshelf-git/server/controllers/LibraryController.js) }

System: Arch Linux
Package: audiobookshelf-git-v2.8.1.r89.g0f7c99d9-1

Steps to reproduce the issue

  1. add new books to library folder
  2. click on "scan" button in library

Audiobookshelf version

v2.8.1

How are you running audiobookshelf?

Built from source of latest git commit

Originally created by @decoherencer on GitHub (Apr 16, 2024). ### Describe the issue While trying to click on "scan" button in libraries, the new books are not being scanned, the server disconnects for a second and reconnects and is stuck in scanning loop. the log: ```FATAL [Server] Unhandled rejection: ReferenceError: structuredClone is not defined, promise: Promise { <rejected> ReferenceError: structuredClone is not defined at LibraryItemScanData.checkLibraryItemData (/snapshot/audiobookshelf-git/server/scanner/LibraryItemScanData.js) at LibraryScanner.scanLibrary (/snapshot/audiobookshelf-git/server/scanner/LibraryScanner.js) at async LibraryScanner.scan (/snapshot/audiobookshelf-git/server/scanner/LibraryScanner.js) at async ApiRouter.scan (/snapshot/audiobookshelf-git/server/controllers/LibraryController.js) } ``` System: Arch Linux Package: audiobookshelf-git-v2.8.1.r89.g0f7c99d9-1 ### Steps to reproduce the issue 1. add new books to library folder 2. click on "scan" button in library ### Audiobookshelf version v2.8.1 ### How are you running audiobookshelf? Built from source of latest git commit
adam added the bug label 2026-04-25 00:00:59 +02:00
adam closed this issue 2026-04-25 00:00:59 +02:00
Author
Owner

@nichwall commented on GitHub (Apr 16, 2024):

Latest git commit being https://github.com/advplyr/audiobookshelf/commit/0f7c99d98965fe26660d93588bcc934dbccc6324

@nichwall commented on GitHub (Apr 16, 2024): Latest git commit being https://github.com/advplyr/audiobookshelf/commit/0f7c99d98965fe26660d93588bcc934dbccc6324
Author
Owner

@advplyr commented on GitHub (Apr 16, 2024):

This is likely because you are using node 16 or below. structuredClone was added in node 17 I believe. We are now using node 20 so upgrade to node 20 and you should be good to go.

@advplyr commented on GitHub (Apr 16, 2024): This is likely because you are using node 16 or below. `structuredClone` was added in node 17 I believe. We are now using node 20 so upgrade to node 20 and you should be good to go.
Author
Owner

@decoherencer commented on GitHub (Apr 17, 2024):

Thanks @nichwall i force refreshed git repo, it's building v2.8.1.r90.gf0caf1a9-1 now

@advplyr Sorry, I thought the same, but I only have the node version of v21.7.2 in the system, and it is building with it.

$ where node
/usr/bin/node
$ node -v
v21.7.2

could you please keep it open until we find solution? 😅

@decoherencer commented on GitHub (Apr 17, 2024): Thanks @nichwall i force refreshed git repo, it's building `v2.8.1.r90.gf0caf1a9-1` now @advplyr Sorry, I thought the same, but I only have the node version of `v21.7.2` in the system, and it is building with it. ``` $ where node /usr/bin/node $ node -v v21.7.2 ``` could you please keep it open until we find solution? :sweat_smile:
Author
Owner

@decoherencer commented on GitHub (Apr 17, 2024):

I tried makepkg --cleanbuild too
it seems in recent pull by @mikiher #2773 server/scanner/LibraryItemScanData.js is updated to add this structuredClone part, so I am not sure if change has to be looked at again 🤔

@decoherencer commented on GitHub (Apr 17, 2024): I tried `makepkg --cleanbuild` too it seems in recent pull by @mikiher #2773 `server/scanner/LibraryItemScanData.js` is updated to add this `structuredClone` part, so I am not sure if change has to be looked at again :thinking:
Author
Owner

@mikiher commented on GitHub (Apr 17, 2024):

Try adding the following line in the init() function in server/server.js:
Logger.info('[Server] node version:', process.versions.node)

Then run the server and see what version is printed. @advplyr's comment is very likely the issue you're facing.

@mikiher commented on GitHub (Apr 17, 2024): Try adding the following line in the init() function in server/server.js: `Logger.info('[Server] node version:', process.versions.node)` Then run the server and see what version is printed. @advplyr's comment is very likely the issue you're facing.
Author
Owner

@decoherencer commented on GitHub (Apr 17, 2024):

Thanks @mikiher
Upon tinkering further ( I am new to nodejs), I found the culprit line in aur pkgbuild
"${srcdir}/${pkgname}"/node_modules/.bin/pkg -t node16-linux -o "${pkgdir}/usr/bin/audiobookshelf"

Also, the pkg repo is archived and doesn't support the latest node. So I changed it to the node18-linux target, which works now. It would be helpful if you could suggest something replacement for pkg in the above line to target the latest node versions in future, like in this case.

@decoherencer commented on GitHub (Apr 17, 2024): Thanks @mikiher Upon tinkering further ( I am new to nodejs), I found the culprit line in [aur pkgbuild ](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=audiobookshelf) ```"${srcdir}/${pkgname}"/node_modules/.bin/pkg -t node16-linux -o "${pkgdir}/usr/bin/audiobookshelf" ``` Also, the `pkg` repo is archived and doesn't support the latest node. So I changed it to the `node18-linux` target, which works now. It would be helpful if you could suggest something replacement for `pkg` in the above line to target the latest node versions in future, like in this case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#1889