Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: blocking IO in async contexts #476

Open
twuebi opened this issue Aug 21, 2024 · 3 comments
Open

bug: blocking IO in async contexts #476

twuebi opened this issue Aug 21, 2024 · 3 comments

Comments

@twuebi
Copy link
Contributor

twuebi commented Aug 21, 2024

Currently, there exist a number of functions used in async contexts that perform blocking IO. This can cause hard to debug issues (https://ryhl.io/blog/async-what-is-blocking/). An initial proposal which replaced std::fs calls on non-wasm targets by tokio::fs calls was done in #458 but rejected as it would have meant not being generic over async runtimes.

@Xuanwo
Copy link
Owner

Xuanwo commented Sep 23, 2024

Should be fixed by our new Context design:

#[derive(Debug, Clone)]
pub struct Context {
fs: Arc<dyn FileRead>,
http: Arc<dyn HttpSend>,
env: Arc<dyn Env>,
}

@twuebi
Copy link
Contributor Author

twuebi commented Sep 30, 2024

Nice!

Browsing a bit, I found some std::fs calls in other places, e.g.

let content = std::fs::read(path).map_err(|err| {

@Xuanwo
Copy link
Owner

Xuanwo commented Sep 30, 2024

Nice!

Browsing a bit, I found some std::fs calls in other places, e.g.

let content = std::fs::read(path).map_err(|err| {

Yep, still working on migrating all usages.

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

No branches or pull requests

2 participants