Skip to content

query-timeout: TIMEOUT 300ms clause on search + item queries #62

Description

@disconsented

Add a SurrealQL TIMEOUT 300ms clause to the two hand-built read queries so the engine itself stops executing once the budget is blown.

Scope

  • Set stmt.timeout on both SelectStatements:
    • Search/list — query_inner, before the debug!(sql = ...) at src/web/query.rs:228.
    • Item detail — get_item, before the debug!(sql = ...) at src/web/item.rs:283.
  • SelectStatement.timeout is an Expr (default Literal::None → no clause). Set it to a duration literal:
    stmt.timeout = Expr::Literal(Literal::Duration(QUERY_TIMEOUT.into()));
  • Share one const QUERY_TIMEOUT: Duration (e.g. in src/web/mod.rs) across both sites.

Verify when implementing

  • Confirm the concrete duration newtype inside Literal::Duration(...) for the sql module and that Duration::into() resolves to it (surrealdb-core 3.1.2, sql/literal.rs:29).
  • Assert stmt.to_sql() contains TIMEOUT 300ms in a unit test (the get_item tests at src/web/item.rs:397 already stand up an in-memory DB to extend).

Parent: #52

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions