Wait for database to load before returning schema#4551
Merged
cloutiertyler merged 1 commit intomasterfrom Mar 4, 2026
Merged
Conversation
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
coolreader18
approved these changes
Mar 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When hitting
/v1/schemawhile 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
Host::wait_for_module(timeout)incrates/client-api/src/lib.rs-- pollsget_module_hostwith exponential backoff (100ms, 200ms, 400ms, 800ms, 1s, 1s, ...) up to the given timeout/v1/schemaroute to usewait_for_module(10s)instead of the immediatemodule()callIf 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