Getting a RecvError() no matter what I do
Opened this issue · 3 comments
I use this library to run a twitter bot, but I must have changed something, and lately every time the cron job actually starts, it stops immediately with a generic error:
2023-11-14T01:00:00.196354Z ERROR tokio_cron_scheduler::job::creator: /home/pi/.cargo/registry/src/index.crates.io-1cd66030c949c28d/tokio-cron-scheduler-0.9.4/src/job/creator.rs: Error running job a67d2389-3be4-4ca8-8b70-8afd7a202170 RecvError(())
and I'm not sure how to debug. I've put the contents of the job into a cron_tweet()
fn, and doing something like:
let hour_offset = 1;
scheduler
.add(
// 6pm MST is midnight UTC
Job::new_async(format!("0 0 {} * * *", hour_offset).as_str(), |_, __| {
Box::pin(async move {
cron_tweet().await;
})
})
.unwrap(),
)
.await
.unwrap();
has the error, but just:
cron_tweet().await;
works fine.
The start of my cron_tweet()
function is:
async fn cron_tweet() -> () {
info!("Starting cron...");
let config: Config = get_config().expect("Getting config failed!");
let dao = match ant_data_farm::connect_config(config.database).await {
Err(e) => {
error!("Failed to initialize database: {}", e);
error!("Ending CRON early!");
return;
}
Ok(dao) => dao,
};
...
where the dao
is a database connection. And I actually see the Starting cron...
logs:
2023-11-14T00:55:45.953573Z INFO ant_who_tweets: projects/ant-who-tweets/src/main.rs: Saw 255 seconds until next job, sleeping for 255 seconds!
2023-11-14T01:00:00.148506Z INFO ant_who_tweets: projects/ant-who-tweets/src/main.rs: Starting cron...
2023-11-14T01:00:00.196354Z ERROR tokio_cron_scheduler::job::creator: /home/pi/.cargo/registry/src/index.crates.io-1cd66030c949c28d/tokio-cron-scheduler-0.9.4/src/job/creator.rs: Error running job a67d2389-3be4-4ca8-8b70-8afd7a202170 RecvError(())
but then immediately the error. The manual way (no scheduler, just calling cron_tweet().await
directly, has all the right logging).
What could RecvError() come from? Why does this happen? It doesn't seem like a bad connection to the DB, or my error!
logs would appear, but they aren't...
version 0.9.4
tokio version 1.35.1
Just had this happen as well. Been running fine for a week then suddenly today I get this in my logs. I have error reporting for my own things and had nothing show up there.
its being reported here, line 96:
tokio-cron-scheduler/src/job/creator.rs
Lines 94 to 104 in da2e310
From what I can gather, tokio has three errors with this name:
seems to have something to do with channels?
Yep, I think there must be some kind of race condition within the library. You can see in my Git history link that very minor things change, and this error no longer affects me today.
Really, I added some logging, and things fixed themselves.
me too...
2024-09-10T07:00:00.282823Z INFO hedon_bot::cron_task: Run go_official_blog 2024-09-11 07:00:00 UTC
2024-09-10T07:00:00.282919Z ERROR tokio_cron_scheduler::job::creator: Error running job 7a8fab45-ab4d-4c5c-b57e-3c77f2dd2b43 RecvError(())
2024-09-10T07:50:00.011838Z INFO hedon_bot::cron_task: Run redis_official_blog 2024-09-10 08:50:00 UTC
2024-09-10T07:50:00.016983Z ERROR tokio_cron_scheduler::job::creator: Error running job 2d6a8cf1-fb6f-48fb-a483-58c5f950b600 RecvError(())
2024-09-10T10:50:00.381384Z INFO hedon_bot::cron_task: Run redis_official_blog 2024-09-10 11:50:00 UTC
2024-09-10T10:50:00.381490Z ERROR tokio_cron_scheduler::job::creator: Error running job 2d6a8cf1-fb6f-48fb-a483-58c5f950b600 RecvError(())