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

warn about sync usage inside async function #1177

Closed
sigmaSd opened this issue Jul 16, 2023 · 0 comments · Fixed by #1178
Closed

warn about sync usage inside async function #1177

sigmaSd opened this issue Jul 16, 2023 · 0 comments · Fixed by #1178

Comments

@sigmaSd
Copy link
Contributor

sigmaSd commented Jul 16, 2023

I think it would be nice to have a lint that warns like this

async function doStuff() {
   Deno.readTextFileSync("") // warning here: using a sync function inside an async function, this blocks deno event loop, you should consider changing it to an async function 
  }

Don't know how this stuff is implemented, but I imagine that sync function blocks tokio executor, so no other async function will proceed, here is an example program that showcases my assumption

setInterval(() => console.log(4), 1000);
//Deno.readTextFileSync("/dev/random"); // if this is uncommented, no logging will be printed
//await Deno.readTextFile("/dev/random"); // if this is uncommneted, logging will still work
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 a pull request may close this issue.

1 participant