Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Crash on failure to download image file #2857

Closed
nichwall opened this issue Apr 17, 2024 · 2 comments
Closed

[Bug]: Crash on failure to download image file #2857

nichwall opened this issue Apr 17, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@nichwall
Copy link
Contributor

Describe the issue

When failing to download an image file during a single match operation, the server crashes. Originally posted by hjk321 in Discord. Not sure exactly what causes the failure.

Steps to reproduce the issue

  1. Failure to download a cover image.

Truncated error message

audiobookshelf-1  | [2024-04-16 23:19:48.688] INFO: [Audnexus] Searching for author "https://api.audnex.us/authors?name=the+forsaken+throne%3A+the+kingfountain+series%2C+book+6"
audiobookshelf-1  | [2024-04-16 23:20:10.456] ERROR: [fileUtils] Failed to download file "/metadata/items/77c10708-3f89-461a-a815-f0ffc5837299/cover" AxiosError: getaddrinfo EAI_AGAIN m.media-amazon.com
audiobookshelf-1  |     at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) {
audiobookshelf-1  |   hostname: 'm.media-amazon.com',
audiobookshelf-1  |   syscall: 'getaddrinfo',
audiobookshelf-1  |   code: 'EAI_AGAIN',
audiobookshelf-1  |   errno: -3001,
audiobookshelf-1  |   config: {
audiobookshelf-1  |     transitional: {
audiobookshelf-1  |       silentJSONParsing: true,
audiobookshelf-1  |       forcedJSONParsing: true,
audiobookshelf-1  |       clarifyTimeoutError: false
audiobookshelf-1  |     },
audiobookshelf-1  |     adapter: [Function: httpAdapter],
audiobookshelf-1  |     transformRequest: [ [Function: transformRequest] ],
audiobookshelf-1  |     transformResponse: [ [Function: transformResponse] ],
audiobookshelf-1  |     timeout: 30000,
audiobookshelf-1  |     xsrfCookieName: 'XSRF-TOKEN',
audiobookshelf-1  |     xsrfHeaderName: 'X-XSRF-TOKEN',
audiobookshelf-1  |     maxContentLength: -1,
audiobookshelf-1  |     maxBodyLength: -1,
audiobookshelf-1  |     env: { FormData: [Function] },
audiobookshelf-1  |     validateStatus: [Function: validateStatus],
audiobookshelf-1  |     headers: {
audiobookshelf-1  |       Accept: 'application/json, text/plain, */*',
audiobookshelf-1  |       'User-Agent': 'axios/0.27.2'
audiobookshelf-1  |     },
audiobookshelf-1  |     url: 'https://m.media-amazon.com/images/I/91AVVZUfl9L.jpg',
audiobookshelf-1  |     method: 'get',
audiobookshelf-1  |     responseType: 'stream',

Audiobookshelf version

2.8.1

How are you running audiobookshelf?

Docker

@nichwall nichwall added the bug Something isn't working label Apr 17, 2024
@advplyr
Copy link
Owner

advplyr commented Apr 20, 2024

I found the original post in Discord since that log isn't showing a crash. The exception was caught correctly in that part of the log but directly after that the crash happened.

With the updates I made a few months ago for crash logs the crashes will have log type FATAL.

audiobookshelf-1  | [2024-04-16 23:20:10.467] ERROR: [CoverManager] Download image file failed for "https://m.media-amazon.com/images/I/91AVVZUfl9L.jpg" getaddrinfo EAI_AGAIN m.media-amazon.com (CoverManager.js:129)
audiobookshelf-1  | [2024-04-16 23:20:10.526] INFO: [LibraryItem] Library item "77c10708-3f89-461a-a815-f0ffc5837299" updated
audiobookshelf-1  | [2024-04-16 23:20:10.530] FATAL: [Server] Unhandled rejection: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client, promise: Promise {
audiobookshelf-1  |   <rejected> Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
audiobookshelf-1  |       at ServerResponse.setHeader (node:_http_outgoing:652:11)
audiobookshelf-1  |       at ServerResponse.header (/node_modules/express/lib/response.js:794:10)
audiobookshelf-1  |       at ServerResponse.send (/node_modules/express/lib/response.js:174:12)
audiobookshelf-1  |       at ServerResponse.json (/node_modules/express/lib/response.js:278:15)
audiobookshelf-1  |       at ApiRouter.updateMedia (/server/controllers/LibraryItemController.js:172:9) {
audiobookshelf-1  |     code: 'ERR_HTTP_HEADERS_SENT'
audiobookshelf-1  |   }
audiobookshelf-1  | } (Server.js:164)

I tracked this one down to #2573 where the response was sent as a 400 in uploadCover and we weren't checking if the response was already sent in updateMedia. I added a check for res.headersSent to handle that. For future reference @mikiher

@advplyr advplyr added the awaiting release Issue is resolved and will be in the next release label Apr 20, 2024
@advplyr
Copy link
Owner

advplyr commented Apr 22, 2024

Fixed in v2.9.0

@advplyr advplyr closed this as completed Apr 22, 2024
@advplyr advplyr removed the awaiting release Issue is resolved and will be in the next release label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants