[Bug]: M4B Conversion via API does not check if a conversion is already in progress - Server Crash #2210

Closed
opened 2026-04-25 00:04:58 +02:00 by adam · 2 comments
Owner

Originally created by @kuldan5853 on GitHub (Aug 24, 2024).

What happened?

If you use the API to initialize an M4B conversion of a library item, it does not check if the current item is already being encoded - if you send the request twice, ABS initializes ffmpeg twice, trying to access the same files (you can watch this very easily because both threads try to update the percentage done on the ABS interface), eventually crashing the server when the second thread tries to access the files.txt file locked by the first process.

This leads to a complete server crash.

What did you expect to happen?

The API should be thread aware and deny a request if an encoding is already in progress / just let the process continue instead of spawning a second encoder.

Steps to reproduce the issue

  1. Start encoding a Library item via the API
  2. Send the same command a second time while the encoding is ongoing

Audiobookshelf version

v2.12.3

How are you running audiobookshelf?

Windows Tray App

What OS is your Audiobookshelf server hosted from?

Windows

If the issue is being seen in the UI, what browsers are you seeing the problem on?

None

Logs

{"timestamp":"2024-08-21 14:13:25.661","source":"    at process.<anonymous> (C:\\snapshot\\audiobookshelf\\server\\Server.js)","message":"[Server] Unhandled rejection: Error: EBUSY: resource busy or locked, unlink 'C:\\Audiobookshelf\\Data\\metadata\\cache\\items\\402d7afe-6672-4524-9516-d70bd423c6bb\\files.txt', promise: Promise {\n  <rejected> [Error: EBUSY: resource busy or locked, unlink 'C:\\Audiobookshelf\\Data\\metadata\\cache\\items\\402d7afe-6672-4524-9516-d70bd423c6bb\\files.txt'] {\n    errno: -4082,\n    code: 'EBUSY',\n    syscall: 'unlink',\n    path: 'C:\\\\Audiobookshelf\\\\Data\\\\metadata\\\\cache\\\\items\\\\402d7afe-6672-4524-9516-d70bd423c6bb\\\\files.txt'\n  }\n}","levelName":"FATAL","level":5}

Additional Notes

No response

Originally created by @kuldan5853 on GitHub (Aug 24, 2024). ### What happened? If you use the API to initialize an M4B conversion of a library item, it does not check if the current item is already being encoded - if you send the request twice, ABS initializes ffmpeg twice, trying to access the same files (you can watch this very easily because both threads try to update the percentage done on the ABS interface), eventually crashing the server when the second thread tries to access the files.txt file locked by the first process. This leads to a complete server crash. ### What did you expect to happen? The API should be thread aware and deny a request if an encoding is already in progress / just let the process continue instead of spawning a second encoder. ### Steps to reproduce the issue 1. Start encoding a Library item via the API 2. Send the same command a second time while the encoding is ongoing ### Audiobookshelf version v2.12.3 ### How are you running audiobookshelf? Windows Tray App ### What OS is your Audiobookshelf server hosted from? Windows ### If the issue is being seen in the UI, what browsers are you seeing the problem on? None ### Logs ```shell {"timestamp":"2024-08-21 14:13:25.661","source":" at process.<anonymous> (C:\\snapshot\\audiobookshelf\\server\\Server.js)","message":"[Server] Unhandled rejection: Error: EBUSY: resource busy or locked, unlink 'C:\\Audiobookshelf\\Data\\metadata\\cache\\items\\402d7afe-6672-4524-9516-d70bd423c6bb\\files.txt', promise: Promise {\n <rejected> [Error: EBUSY: resource busy or locked, unlink 'C:\\Audiobookshelf\\Data\\metadata\\cache\\items\\402d7afe-6672-4524-9516-d70bd423c6bb\\files.txt'] {\n errno: -4082,\n code: 'EBUSY',\n syscall: 'unlink',\n path: 'C:\\\\Audiobookshelf\\\\Data\\\\metadata\\\\cache\\\\items\\\\402d7afe-6672-4524-9516-d70bd423c6bb\\\\files.txt'\n }\n}","levelName":"FATAL","level":5} ``` ### Additional Notes _No response_
adam added the bug label 2026-04-25 00:04:58 +02:00
adam closed this issue 2026-04-25 00:04:59 +02:00
Author
Owner

@kuldan5853 commented on GitHub (Aug 24, 2024):

As a note - there is a docker tool on the docker hub called abs-autoconverter that uses the API to watch the library for multi-track files to automatically trigger a conversion to m4b using the API. This is run via cron at set intervals (since there seems to be no way in the API to check the progress of an encode), and if a book takes longer than expected to encode, the tool will send an encode request for the same book again and this will trigger the server trash.

@kuldan5853 commented on GitHub (Aug 24, 2024): As a note - there is a docker tool on the docker hub called abs-autoconverter that uses the API to watch the library for multi-track files to automatically trigger a conversion to m4b using the API. This is run via cron at set intervals (since there seems to be no way in the API to check the progress of an encode), and if a book takes longer than expected to encode, the tool will send an encode request for the same book again and this will trigger the server trash.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 31, 2024):

Fixed in v2.13.0.

@github-actions[bot] commented on GitHub (Aug 31, 2024): Fixed in [v2.13.0](https://github.com/advplyr/audiobookshelf/releases/tag/v2.13.0).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#2210