Skip to content

Conversation

cdrini
Copy link
Collaborator

@cdrini cdrini commented Oct 7, 2025

Follow-up from #11332 . The issue was exacerbated by the web nodes becoming saturated when covers was slow, due to this request, which did not have a timeout.

Technical

Testing

Tested locally by adding a sleep to coverstore:

--- a/openlibrary/coverstore/code.py
+++ b/openlibrary/coverstore/code.py
@@ -6,6 +6,7 @@ import json
 import logging
 import os
 import textwrap
+from time import sleep
 from typing import cast

 import requests
@@ -403,6 +404,7 @@ def parse_tarindex(file):

 class cover_details:
     def GET(self, category, key, value):
+        sleep(10)
         d = _query(category, key, value)

         if key == 'id':

And observed that on loading a book page, the page did not wait 10 seconds, but instead responded after ~3 , and without the style="aspect-ratio: ..." tag on the image.

Screenshot

Stakeholders

@Copilot Copilot AI review requested due to automatic review settings October 7, 2025 15:35
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a timeout to the requests.get() call when fetching cover information to prevent the site from becoming unresponsive when the coverstore service is slow.

  • Adds a 3-second timeout to the HTTP request
  • Expands exception handling to catch request-specific exceptions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@mekarpeles mekarpeles merged commit 5653f72 into internetarchive:master Oct 7, 2025
4 checks passed
@mekarpeles mekarpeles self-assigned this Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants