-
Notifications
You must be signed in to change notification settings - Fork 878
Description
I know procedures are in beta and so there are likely issues, but I just wanted to report the issue I've been having since I couldnt find it in your issues list.
With a basic HTTP GET request, it sometimes succeeds, and sometimes fails with the somewhat unhelpful error:
error sending request for url (some-url.com)
Code to reproduce
#[table(accessor=schedule, scheduled(do_work))]
pub struct Schedule {
#[primary_key]
#[auto_inc]
pub id: u64,
pub scheduled_at: ScheduleAt,
}
#[reducer(init)]
pub fn init(ctx: &ReducerContext) {
if ctx.db.schedule().count() == 0 {
ctx.db.schedule().insert(Schedule {
id: 0,
scheduled_at: ScheduleAt::Time(ctx.timestamp),
});
}
}
#[procedure]
pub fn do_work(ctx: &mut ProcedureContext, _schedule: Schedule) {
match ctx.http.get("https://httpbin.org/get") {
Ok(res) => {
log::info!(
"Success, {} {:?}",
res.status(),
res.into_body().into_string()
);
}
Err(err) => {
log::info!("Failed {}", err);
}
}
}When deploying against local server, the HTTP request usually succeeds the first time it's run. e.g.
- terminal 1:
spacetime start - terminal 2:
spacetime delete --server local \
&& spacetime publish --server local \
&& spacetime logs --server local --follow
Success, 200 OK ...
However, if I delete and republish the module without restarting local server, the HTTP request usually fails:
Failed error sending request for url (https://httpbin.org/get)
If I kill and restart the local server on terminal 1, and then re-run the commands to delete and publish the module, it usually works again.
Note that it doesnt always follow this pattern. In fact, this pattern that I've observed may just be a coincidence and is completely unrelated. Either way, I can run this chain of commands to delete and re-publish my module without changing my code or environment; sometimes the HTTP request succeeds, sometimes it fails.
Debug info
Language: rust
spacetimedb version: 2.0.2, features: unstable
spacetime cli Commit: bc4fcec
spacetimedb tool version 2.0.2; spacetimedb-lib version 2.0.2;
OS: Debian 13.3