OPDS download crashes the container with `TypeError: Invalid state: Controller is already closed` (ERR_INVALID_STATE)
Downloading a freshly aligned read-aloud over OPDS from KOReader on a Kindle shows "Downloading..." for about 20 seconds, then fails to save the file. The Storyteller container dies at the same moment with FATAL: uncaught exception ... TypeError: Invalid state: Controller is already closed and code: 'ERR_INVALID_STATE', thrown from ReadableStreamDefaultController.enqueue via ReadStream.onData. Running the v3 beta.
Resolution: The crash is Storyteller enqueueing into an already-closed response stream when the OPDS client aborts or times out mid-download — an unhandled rejection that takes the whole Node process with it. It reproduces reliably when the acquisition link points at the read-aloud, because that file bundles the audio and can be hundreds of megabytes, which older/slower clients like a Kindle give up on. The practical fix is to change what OPDS advertises: in the OPDS settings, set the download format to "ebook, or readaloud if unavailable" instead of always serving the read-aloud, after which the download completes normally. You can verify what your feed is offering by inspecting the acquisition links in the OPDS XML — .../files?format=readaloud is the large bundle, and there is no separate ebook-only link unless that setting is changed. The container crash itself is a bug worth reporting separately; the setting only avoids triggering it.