Skip to content

fix(thumbnail): add timeout protection for large image processing#229

Open
BillionClaw wants to merge 1 commit intoDioCrafts:mainfrom
BillionClaw:clawoss/fix/thumbnail-generation-timeout
Open

fix(thumbnail): add timeout protection for large image processing#229
BillionClaw wants to merge 1 commit intoDioCrafts:mainfrom
BillionClaw:clawoss/fix/thumbnail-generation-timeout

Conversation

@BillionClaw
Copy link
Contributor

Problem

Thumbnail generation for large images could hang indefinitely because there was no timeout protection on the spawn_blocking call that processes images.

Solution

Add configurable timeout (default 30s) for thumbnail generation operations:

  • Added thumbnail_generation_ms to TimeoutConfig with 30 second default
  • Added generation_timeout field to ThumbnailService
  • Wrapped spawn_blocking call in tokio::time::timeout to prevent hanging
  • Updated DI to pass timeout from config
  • Updated tests to provide timeout parameter

Testing

  • cargo check --lib passes
  • Code compiles with no new warnings

Related

This fix prevents potential DoS issues where processing very large images could exhaust worker threads.

Add configurable timeout for thumbnail generation to prevent hanging
when processing very large images. The default timeout is 30 seconds.

Changes:
- Add thumbnail_generation_ms to TimeoutConfig (default: 30s)
- Add generation_timeout field to ThumbnailService
- Wrap spawn_blocking in tokio::time::timeout
- Update DI to pass timeout from config
- Update tests to provide timeout parameter
@BillionClaw BillionClaw requested a review from DioCrafts as a code owner March 18, 2026 03:53
@DioCrafts
Copy link
Owner

may fix the conflicts file ? @BillionClaw

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