Description
Summary
HTTP requests made from a procedure are capped at 500 ms. The docs on Timeout in the Rust module library say:
All HTTP requests in SpacetimeDB are subject to a maximum timeout of 500 milliseconds.
That is too short to call an LLM or an agent, which is one of the main reasons to make an HTTP request from a module in the first place. I'd like the maximum to be much higher, or configurable, so a procedure can wait for a model to answer.
Motivation
I'm building a small multiplayer game on Maincloud where each player writes a prompt and a model turns it into a script for their bot. The natural design is one procedure: take the prompt, call the model, validate the script, store it in a transaction.
A model call takes seconds to tens of seconds, and an agent that makes several model calls or uses tools can take minutes. None of that fits in 500 ms, so the module can't make the call. What I had to build instead:
- A separate service (a Cloudflare Worker) that exists only to wait for the model.
- A poke and a callback. The procedure sends the job to the Worker, which answers "accepted" at once to fit the limit. When the model is done, the Worker calls a reducer over the SpacetimeDB HTTP API to deliver the result.
- A shared secret in both directions, because the callback reducer is public and has to tell the Worker apart from anyone else.
- A scheduled timeout table, because the module no longer sees the request fail. It has to notice by itself when the Worker never calls back.
- Retry state split across two systems. When the module rejects a script, it has to start a new poke with the error attached, instead of looping inside one procedure.
All of this is infrastructure that exists because of the timeout and nothing else. It also undoes the main appeal of procedures, which is keeping the logic and the data in one place.
The same limit affects ordinary requests too. I ship logs to a logging service from a scheduled procedure, and I had to pick the service's region to match Maincloud's and keep batches small so that a request reliably finishes in time.
Proposed solution
Raise the maximum, and let the module choose a timeout up to it with the existing Timeout extension:
- A ceiling in minutes, not seconds. A single model call is often 30 to 60 s, and an agent run is commonly several minutes. A ceiling of 10 minutes or more would cover agent work; 60 s would only cover single calls.
- The default can stay short. Modules that want a long request would ask for it per request, so nothing changes for existing code.
- Configurable on self-hosted if a fixed number is a concern, with Maincloud choosing its own ceiling.
A procedure doesn't hold a transaction open while it waits on HTTP, so a long request should not block reducers. If the 500 ms limit protects something else (host threads, memory, billing), a per-database limit on concurrent long requests would address that without ruling out the use case.
Alternatives considered
- The external worker with a callback, described above. It works, but it is a second service, a second deploy, and a second place for things to fail.
- Streaming or polling from the module. A procedure could start a job and poll for the result on a schedule, but that still needs an external service to hold the model connection, so it removes none of the parts above.
- Calling the model from the client. That puts the API key and the validation on a machine the player controls.
Activity
rohanranjan0902 commentedon Nov 13, 2026
@eranknafo2001 Please Review my changes
bfops commentedon Nov 18, 2026
Thank you for filing this! We're aware of these issues and we're working on a general solution for long-running procedures of all shapes and sizes.
aasoni commentedon Nov 20, 2026
Just wanted give some more info here as well. Currently the 500ms timeout is an incorrect inline doc comment. Users can set a timeout of up to 180s for http requests from inside a procedure. See procedure docs.