Skip to content

fix(archive): make probe() async; remove block_on inside tokio runtime#2

Merged
bravo1goingdark merged 1 commit into
mainfrom
fix/archiver-probe-block-on
May 5, 2026
Merged

fix(archive): make probe() async; remove block_on inside tokio runtime#2
bravo1goingdark merged 1 commit into
mainfrom
fix/archiver-probe-block-on

Conversation

@bravo1goingdark
Copy link
Copy Markdown
Owner

Summary

`Archiver::probe()` was synchronous but called `Handle::current().block_on()` on an async S3 head request. The startup path that invokes it (`Server::run_inner`) is async — sitting inside the tokio runtime created in `keplor-cli/main.rs:run_server`. tokio explicitly disallows nested `block_on`, so anyone enabling `--features s3` and configuring `[archive]` hits this immediately on startup:

```
thread 'main' panicked at crates/keplor-store/src/archive.rs:74:49:
Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.
```

This is the first time the s3 feature shipped live, so the bug had no production exposure before now.

Fix

  • `Archiver::probe()` → async fn, awaits `self.client.head` directly.
  • Single caller in `keplor-server/src/server.rs:304` updated to `.await` it.

3-line change.

Verified

End-to-end against a real Cloudflare R2 bucket — startup log:

```
{"level":"INFO","message":"event archival configured — S3 connectivity verified","bucket":"keplor-log","archive_after_hours":720,"archive_threshold_mb":15000,"interval_secs":3600}
```

`/health` 200, no panic.

Test plan

  • cargo build --release -p keplor-cli --features s3
  • Live startup against R2 bucket with valid credentials → "S3 connectivity verified" message appears
  • Live startup against bogus credentials should now fail-and-disable archival cleanly (probe returns Err, archival disabled, server keeps running)

Archiver::probe() was synchronous but called Handle::current().block_on()
on an async S3 head request. The startup path that invokes it sits
inside a tokio runtime (Server::run_inner is async, called from
rt.block_on in keplor-cli/main.rs), and tokio explicitly disallows
nested block_on — abort with 'Cannot start a runtime from within a
runtime'. Anyone enabling --features s3 and configuring [archive] hits
this immediately on startup; this is the first time we shipped the
feature live.

Make probe() async and .await it at the call site. Verified end-to-end
against a Cloudflare R2 bucket: 'event archival configured — S3
connectivity verified' on first start.
@bravo1goingdark bravo1goingdark force-pushed the fix/archiver-probe-block-on branch from 8915586 to 3d806de Compare May 5, 2026 17:26
@bravo1goingdark bravo1goingdark merged commit 409be58 into main May 5, 2026
4 of 5 checks passed
@bravo1goingdark bravo1goingdark deleted the fix/archiver-probe-block-on branch May 5, 2026 17:29
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.

1 participant