Skip to content

Wait for database to load before returning schema#4551

Merged
cloutiertyler merged 1 commit intomasterfrom
bot/schema-wait-for-load
Mar 4, 2026
Merged

Wait for database to load before returning schema#4551
cloutiertyler merged 1 commit intomasterfrom
bot/schema-wait-for-load

Conversation

@clockwork-labs-bot
Copy link
Collaborator

Summary

When hitting /v1/schema while a database is still loading (replaying the log, running init reducers, etc.), the endpoint returned a 500 error because the module host was not yet available.

Changes

  • Add Host::wait_for_module(timeout) in crates/client-api/src/lib.rs -- polls get_module_host with exponential backoff (100ms, 200ms, 400ms, 800ms, 1s, 1s, ...) up to the given timeout
  • Update the /v1/schema route to use wait_for_module(10s) instead of the immediate module() call

If the database finishes loading within 10 seconds, the schema is returned normally. If it does not load in time, the existing 500 error is returned (same behavior as before, just delayed).

No other routes are changed -- this is scoped to the schema endpoint per the issue description. Other routes (SQL, call, etc.) could adopt the same pattern if needed.

Fixes clockworklabs/SpacetimeDBPrivate#2748

When hitting /v1/schema while a database is still loading (replaying
the log, running init reducers, etc.), the endpoint returned a 500
error because the module host was not yet available.

Add Host::wait_for_module() which retries with exponential backoff
(100ms, 200ms, ... up to 1s intervals) for a configurable timeout.
The schema route uses a 10-second timeout before giving up.

Fixes clockworklabs/SpacetimeDBPrivate#2748
@cloutiertyler cloutiertyler added this pull request to the merge queue Mar 4, 2026
Merged via the queue into master with commit e991421 Mar 4, 2026
34 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