[PR #4716] [MERGED] Async Cover Search #4324

Closed
opened 2026-04-25 00:19:17 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/4716
Author: @mikiher
Created: 10/2/2025
Status: Merged
Merged: 10/3/2025
Merged by: @advplyr

Base: masterHead: async-cover-search


📝 Commits (8)

  • a164c17 Reduce provider timout to 10 secs, Shorten error message
  • 7630dbd Replace cover search with streaming version
  • 26f949b Remove audiobookcovers from provider list
  • c6dabd2 Shorten timeout and error message for remaining providers
  • dbb5ee7 Revert removal of audiobookcovers provider
  • 20de2ea Add "Best" option to book cover search
  • 7e89b97 Tidy up cover search console logging and error toasts
  • 1280ddf ui/ux disable inputs while cover search in progress, add padding on empty state texts

📊 Changes

13 files changed (+531 additions, -40 deletions)

View changed files

📝 client/components/modals/item/tabs/Cover.vue (+145 -19)
📝 client/strings/en-us.json (+2 -0)
📝 server/SocketAuthority.js (+104 -0)
📝 server/finders/BookFinder.js (+9 -1)
server/managers/CoverSearchManager.js (+251 -0)
📝 server/providers/Audible.js (+3 -3)
📝 server/providers/AudiobookCovers.js (+2 -2)
📝 server/providers/Audnexus.js (+3 -3)
📝 server/providers/CustomProviderAdapter.js (+2 -2)
📝 server/providers/FantLab.js (+4 -4)
📝 server/providers/GoogleBooks.js (+2 -2)
📝 server/providers/OpenLibrary.js (+2 -2)
📝 server/providers/iTunes.js (+2 -2)

📄 Description

Brief summary

This replaces the existing synchronous and sequential cover search with an asynchrounous and parallel search.

Which issue is fixed?

These's no current issue, although currently cover search with All option selected always times out and returns no results due to a faulty AudiobooksCovers provider (backend always times out). This resolves the issue thoroughly, by replacing the existing synchronous and sequential provider search with an asynchronous (using WebSockets) and parallel search.

In-depth Description

Server

  1. New CoverSearchManager (server/managers/CoverSearchManager.js)
    • Handles parallel provider searches instead of sequential
    • Each provider has a 10 second timeout
    • Uses AbortController for proper cancellation
    • Tracks active searches by requestId
    • Streams results as they arrive via callbacks
  2. SocketAuthority Updates (server/SocketAuthority.js)
    • Added WebSocket event handlers:
      • search_covers - Starts a new search
      • cancel_cover_search - Cancels active search
    • Emits events back to client:
      • cover_search_result - Streaming results from each provider
      • cover_search_complete - All providers finished
      • cover_search_error - Fatal errors
      • cover_search_provider_error - Individual provider failures
      • cover_search_cancelled - Cancellation confirmed
    • Auto-cleanup on socket disconnect
  3. Reduced provider request timeout from 30 seconds to 10.
  4. Shortened lengthy axios error messages

Client

Updated Cover.vue:

  • Covers are shown as they arrive.
  • Improved UX with Cancel button
  • Generates unique request IDs: cover-search-{timestamp}-{random}
  • Sets up/removes WebSocket listeners on mount/unmount
  • Handles streaming results incrementally
  • Cancels searches automatically when:
    • Component is unmounted (tab switch)
    • Modal is closed
    • User presses Cancel
    • WebSocket disconnects

How have you tested this?

  • Tested on many book covers
  • Since audiobookcovers providers is currently faulty 100% of the time, this allowed testing timeout and provider failure

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/4716 **Author:** [@mikiher](https://github.com/mikiher) **Created:** 10/2/2025 **Status:** ✅ Merged **Merged:** 10/3/2025 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `async-cover-search` --- ### 📝 Commits (8) - [`a164c17`](https://github.com/advplyr/audiobookshelf/commit/a164c17d38fb730e6738832a4ec9c13bcced9c20) Reduce provider timout to 10 secs, Shorten error message - [`7630dbd`](https://github.com/advplyr/audiobookshelf/commit/7630dbdcb7c3fb3a64a5878265d435a715863795) Replace cover search with streaming version - [`26f949b`](https://github.com/advplyr/audiobookshelf/commit/26f949b9bae7f8de82305d5b55db4e2f84ad2cec) Remove audiobookcovers from provider list - [`c6dabd2`](https://github.com/advplyr/audiobookshelf/commit/c6dabd262087381a127cbca1915ab9da0d04caa5) Shorten timeout and error message for remaining providers - [`dbb5ee7`](https://github.com/advplyr/audiobookshelf/commit/dbb5ee79acc1bdf680bc8cf1dbd24c2d9d24dbc5) Revert removal of audiobookcovers provider - [`20de2ea`](https://github.com/advplyr/audiobookshelf/commit/20de2ea388a09f99ef2ace9829406be1d5a934e8) Add "Best" option to book cover search - [`7e89b97`](https://github.com/advplyr/audiobookshelf/commit/7e89b97a6d0e5f95f239368bf626543620005d07) Tidy up cover search console logging and error toasts - [`1280ddf`](https://github.com/advplyr/audiobookshelf/commit/1280ddfe7420e34ed922ee3851a8fd081ffba42b) ui/ux disable inputs while cover search in progress, add padding on empty state texts ### 📊 Changes **13 files changed** (+531 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `client/components/modals/item/tabs/Cover.vue` (+145 -19) 📝 `client/strings/en-us.json` (+2 -0) 📝 `server/SocketAuthority.js` (+104 -0) 📝 `server/finders/BookFinder.js` (+9 -1) ➕ `server/managers/CoverSearchManager.js` (+251 -0) 📝 `server/providers/Audible.js` (+3 -3) 📝 `server/providers/AudiobookCovers.js` (+2 -2) 📝 `server/providers/Audnexus.js` (+3 -3) 📝 `server/providers/CustomProviderAdapter.js` (+2 -2) 📝 `server/providers/FantLab.js` (+4 -4) 📝 `server/providers/GoogleBooks.js` (+2 -2) 📝 `server/providers/OpenLibrary.js` (+2 -2) 📝 `server/providers/iTunes.js` (+2 -2) </details> ### 📄 Description ## Brief summary This replaces the existing synchronous and sequential cover search with an asynchrounous and parallel search. ## Which issue is fixed? These's no current issue, although currently cover search with `All` option selected always times out and returns no results due to a faulty AudiobooksCovers provider (backend always times out). This resolves the issue thoroughly, by replacing the existing synchronous and sequential provider search with an asynchronous (using WebSockets) and parallel search. ## In-depth Description ### Server 1. New CoverSearchManager (server/managers/CoverSearchManager.js) - Handles parallel provider searches instead of sequential - Each provider has a 10 second timeout - Uses AbortController for proper cancellation - Tracks active searches by requestId - Streams results as they arrive via callbacks 2. SocketAuthority Updates (server/SocketAuthority.js) - Added WebSocket event handlers: - search_covers - Starts a new search - cancel_cover_search - Cancels active search - Emits events back to client: - cover_search_result - Streaming results from each provider - cover_search_complete - All providers finished - cover_search_error - Fatal errors - cover_search_provider_error - Individual provider failures - cover_search_cancelled - Cancellation confirmed - Auto-cleanup on socket disconnect 3. Reduced provider request timeout from 30 seconds to 10. 4. Shortened lengthy axios error messages ### Client Updated Cover.vue: - Covers are shown as they arrive. - Improved UX with Cancel button - Generates unique request IDs: cover-search-{timestamp}-{random} - Sets up/removes WebSocket listeners on mount/unmount - Handles streaming results incrementally - Cancels searches automatically when: - Component is unmounted (tab switch) - Modal is closed - User presses Cancel - WebSocket disconnects ## How have you tested this? - Tested on many book covers - Since audiobookcovers providers is currently faulty 100% of the time, this allowed testing timeout and provider failure --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:19:17 +02:00
adam closed this issue 2026-04-25 00:19:17 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4324