Skip to content

Fix image generation request timeout#1231

Closed
szkocot wants to merge 1 commit intolemonade-sdk:mainfrom
szkocot:1222-timeout-while-waiting-for-image-generation
Closed

Fix image generation request timeout#1231
szkocot wants to merge 1 commit intolemonade-sdk:mainfrom
szkocot:1222-timeout-while-waiting-for-image-generation

Conversation

@szkocot
Copy link
Copy Markdown
Contributor

@szkocot szkocot commented Feb 28, 2026

Summary

Fixes #1222.

Image generation requests for sd-cpp could time out after 10 minutes even while the backend was still actively generating the image.
This change removes the hardcoded timeout behavior and adds a configurable server-side setting for image request timeouts.

Changes

  • replace the hardcoded 600 second Stable Diffusion request timeout
  • add a new server config option:
    • CLI: --image-request-timeout <seconds>
    • env var: LEMONADE_IMAGE_REQUEST_TIMEOUT=<seconds>
  • default image_request_timeout to 0 meaning no overall timeout
  • apply the setting consistently to:
    • image generations
    • image edits
    • image variations
  • update the frontend recipe-options mirror so config metadata stays in sync with the server

Behavior Before

Stable Diffusion requests used a fixed 10 minute timeout in the backend forwarding layer. Long-running image generation jobs could fail
with a network timeout even though sd-server was still processing the request.

Behavior After

Stable Diffusion image requests now use a configurable timeout, with the default set to no overall timeout.

Examples:

lemonade-server serve --image-request-timeout 1800

LEMONADE_IMAGE_REQUEST_TIMEOUT=1800 lemonade-server serve

0 disables the timeout entirely.

## Testing

- built lemonade-router successfully:
    - cmake --build --preset default --target lemonade-router

## Notes

- this setting is implemented in the existing server config / recipe options path
- the fix is server-side, so it applies to CLI, web app, and other clients using the same server

@jeremyfowers
Copy link
Copy Markdown
Member

Thanks @szkocot!

im wondering though do we really need the timeout at all? Why not just set it to 0 and skip the env var or CLI option?

@szkocot
Copy link
Copy Markdown
Contributor Author

szkocot commented Mar 2, 2026

@jeremyfowers Defaulting to 0 avoids surprising long-running jobs, but keeping the option is still useful for production or shared deployments where operators may want a safety limit (hung backends, resource control, load balancing, etc.). It’s basically flexibility at no cost for users who don’t need it.

@jeremyfowers
Copy link
Copy Markdown
Member

Looks like @superm1 is merging #1272 which is highly related.

@szkocot is it ok for you to just set the new global timeout to 0 for you use case, or do you still want a specific change for image gen?

If you want something specific for image gen, please change this PR so that it has just the env var, not the CLI arg, and the imagegen timeout var supercedes the global timeout for image gen.

@szkocot
Copy link
Copy Markdown
Contributor Author

szkocot commented Mar 4, 2026

Yes, sure.

@szkocot szkocot force-pushed the 1222-timeout-while-waiting-for-image-generation branch from 345af67 to 23c0a45 Compare March 17, 2026 20:24
@jeremyfowers
Copy link
Copy Markdown
Member

Looks like @superm1 is merging #1272 which is highly related.

@szkocot is it ok for you to just set the new global timeout to 0 for you use case, or do you still want a specific change for image gen?

If you want something specific for image gen, please change this PR so that it has just the env var, not the CLI arg, and the imagegen timeout var supercedes the global timeout for image gen.

#1422 makes sure that the global timeout applies to image generation, which solves the core issue.

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.

Timeout while waiting for image generation

2 participants