[Bug]: Direct Play downloads entire file before playing in browser #492

Closed
opened 2026-04-24 23:11:05 +02:00 by adam · 3 comments
Owner

Originally created by @alexmaras on GitHub (Jun 29, 2022).

Describe the issue

When a certain series of steps are taken, playback for Direct Play (/s/item URLs) doesn't begin until the entire file has downloaded. The following error shows up in the client console when this happens:

Failed to load ‘https://<domain-name>/s/item/li_sjgkfftildydzuvihl/blah.m4b?token=xxxx’. A ServiceWorker intercepted the request and encountered an unexpected error.

Once this error has triggered, it will always fail with this error until the app is hard-reloaded on client side. I presume this results in the ServiceWorker resetting in some way. After hard-reloading the page, the playback starts working again as expected, starting almost immediately regardless of chapter played or download status. The network page in the browser console will show the file not yet downloaded when playback starts.

The error happens the same way whether using the docker image from advplyr/audiobookshelf:edge or my own docker build from the git repo.

Steps to reproduce the issue

  1. Start playing an item that supports Direct Play in a browser
  2. reload the page while the audio is playing
  3. start playing a different book as soon as the page loads
  4. see ServiceWorker intercepted the request error in console, playback will not begin until the whole file has downloaded

Audiobookshelf version

2.0.22

How are you running audiobookshelf?

Docker

Originally created by @alexmaras on GitHub (Jun 29, 2022). ### Describe the issue When a certain series of steps are taken, playback for Direct Play (`/s/item` URLs) doesn't begin until the entire file has downloaded. The following error shows up in the client console when this happens: ``` Failed to load ‘https://<domain-name>/s/item/li_sjgkfftildydzuvihl/blah.m4b?token=xxxx’. A ServiceWorker intercepted the request and encountered an unexpected error. ``` Once this error has triggered, it will always fail with this error until the app is hard-reloaded on client side. I presume this results in the ServiceWorker resetting in some way. After hard-reloading the page, the playback starts working again as expected, starting almost immediately regardless of chapter played or download status. The network page in the browser console will show the file not yet downloaded when playback starts. The error happens the same way whether using the docker image from `advplyr/audiobookshelf:edge` or my own `docker build` from the git repo. ### Steps to reproduce the issue 1. Start playing an item that supports Direct Play in a browser 2. reload the page while the audio is playing 3. start playing a different book as soon as the page loads 4. see `ServiceWorker intercepted the request` error in console, playback will not begin until the whole file has downloaded ### Audiobookshelf version 2.0.22 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:11:05 +02:00
adam closed this issue 2026-04-24 23:11:06 +02:00
Author
Owner

@alexmaras commented on GitHub (Jun 29, 2022):

Just a potential PR here - There may be other ways to solve this issue, but it does seem to be caused by the workbox nuxt pwa library. Disabling that functionality makes the application behave as expected.

https://github.com/advplyr/audiobookshelf/pull/791

@alexmaras commented on GitHub (Jun 29, 2022): Just a potential PR here - There may be other ways to solve this issue, but it does seem to be caused by the workbox nuxt pwa library. Disabling that functionality makes the application behave as expected. https://github.com/advplyr/audiobookshelf/pull/791
Author
Owner

@advplyr commented on GitHub (Jun 29, 2022):

Good catch. I wonder if this changes how the client is requesting chunks from the server because there are a few issues about that. When I was testing the HTML5 audio player for direct play it was requesting the entire file and I never got to the bottom of it.

@advplyr commented on GitHub (Jun 29, 2022): Good catch. I wonder if this changes how the client is requesting chunks from the server because there are a few issues about that. When I was testing the HTML5 audio player for direct play it was requesting the entire file and I never got to the bottom of it.
Author
Owner

@alexmaras commented on GitHub (Jun 29, 2022):

This seems to be working well for me now. I can't make it fail anymore with the latest changes after pulling :edge again. I'll close this for now. This may also resolve this: https://github.com/advplyr/audiobookshelf/issues/658

@alexmaras commented on GitHub (Jun 29, 2022): This seems to be working well for me now. I can't make it fail anymore with the latest changes after pulling `:edge` again. I'll close this for now. This may also resolve this: https://github.com/advplyr/audiobookshelf/issues/658
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#492