Skip to content

Support per-request timeouts for generated client calls #6020

Open

Description

@onism0106

Problem

In Serverpod 4.1.1, connectionTimeout is configured when constructing the generated Client and is final. Generated RPC methods do not expose a per-request timeout option.

This makes it inconvenient to use different timeouts for different operations within the same authenticated client.

For example:

  • Regular CRUD calls should time out after 20 seconds.
  • AI generation calls may need up to 120 seconds.

Current workarounds

Adding Future.timeout() can shorten the caller's wait, but cannot extend the underlying client's timeout. It also does not cancel the underlying request.

Creating a separate Client with a longer timeout requires additional client lifecycle and authentication setup solely to change the timeout.

Proposed feature

Provide a way to override the timeout for an individual RPC call while retaining the Client's configured timeout as the default.

An illustrative API could be:

await client.ai.generate(
  prompt,
  // Client-side transport option, not an endpoint parameter.
  callOptions: RpcCallOptions(
    timeout: Duration(seconds: 120),
  ),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions