Skip to content

Add timeout to network fetches in scrape_me and online scrape_html - #2032

Open
bunlongheng wants to merge 2 commits into
hhursev:mainfrom
bunlongheng:fix/missing-http-timeout
Open

Add timeout to network fetches in scrape_me and online scrape_html#2032
bunlongheng wants to merge 2 commits into
hhursev:mainfrom
bunlongheng:fix/missing-http-timeout

Conversation

@bunlongheng

Copy link
Copy Markdown

Both fetch paths that reach out to a remote URL have no timeout, so a server that accepts the connection but never responds hangs the caller forever. scrape_me() does urlopen(Request(url, headers=HEADERS)).read() and the online branch of scrape_html() does requests.get(url=org_url, headers=HEADERS).text, neither of which passes timeout=, and neither urllib nor requests sets a default. I added a 30s timeout to both. It's a small change but it means a slow or hostile host can no longer wedge the calling thread indefinitely. Happy to make the value configurable if you'd rather it live in settings.

bunlongheng and others added 2 commits August 8, 2026 16:16
Both urlopen() and requests.get() calls that fetch a user-supplied URL
had no timeout, allowing a slow or hostile server to hang the calling
thread indefinitely. Added timeout=30 to both fetch paths.
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