Skip to content

fix: add time bounds to /orders endpoint to prevent timeouts#898

Merged
0xaslan merged 4 commits intomainfrom
at/fix-orders-timeout
Mar 16, 2026
Merged

fix: add time bounds to /orders endpoint to prevent timeouts#898
0xaslan merged 4 commits intomainfrom
at/fix-orders-timeout

Conversation

@0xaslan
Copy link
Copy Markdown
Collaborator

@0xaslan 0xaslan commented Mar 14, 2026

Summary

  • The /orders endpoint timed out (504) on busy pools like SUI_USDC because get_orders_status scanned the entire order event history with no time constraint
  • Added start_time and end_time query params to both CTEs (latest_events and placed_events), reusing the existing ParameterUtil trait
  • Defaults to last 7 days if start_time is omitted, now if end_time is omitted — callers can widen the window as needed

Test plan

  • Deploy to staging and hit /orders on SUI_USDC pool — confirm it returns within 1-2s
  • Verify default (no params) returns last 7 days of orders
  • Verify explicit start_time/end_time params correctly narrow results
  • Verify status and limit filters still work as before

🤖 Generated with Claude Code

0xaslan and others added 3 commits March 14, 2026 07:51
…pools

The get_orders_status query scanned the entire order history for a pool
with no time constraint, causing 504s on high-volume pools like SUI_USDC.

Add start_time/end_time query params (defaulting to last 7 days) so
callers control the scan window and no single query can blow up the DB.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread crates/server/src/server.rs Outdated
let end_time = params.end_time();
let start_time = params
.start_time()
.unwrap_or_else(|| end_time - 7 * 24 * 60 * 60 * 1000);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: do we want to make this default time range configurable?

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@0xaslan 0xaslan merged commit b7b65c9 into main Mar 16, 2026
3 checks passed
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.

3 participants