Northern Savage
Northern Savage•6mo ago

await promise does not yield control

https://github.com/denoland/deno/issues/24360 Is this a bug or not? If so, is it a bug of Deno? of V8? of JS?
GitHub
await promise does not guarantee the yield of control flow · Issu...
deno 1.44.0 (release, aarch64-apple-darwin) v8 12.6.228.3 typescript 5.4.5 Consider (async ()=>{ for(;;) { await new Promise(res => { res(undefined) }) } })(); await new Promise(res => { s...
1 Reply
Deno AI Helper
Deno AI Helper•6mo ago
Based on the documentation, Deno supports top-level await which allows you to use the await keyword without having to wrap your code in an async IIFE. However, if the awaited promise never resolves, this could be due to a bug in the code. The documentation mentions that Deno will show an error along with a stack trace of the unresolved promise, which is an improvement to help developers identify where the problem lies. Regarding the issue you're experiencing with await promise not yielding control, it's important to ensure that the promise you're awaiting is actually designed to resolve. If it's intentionally or unintentionally created to never resolve, then this behavior is expected and not a bug in Deno, V8, or JavaScript itself. It's a logical error in the code where the promise is created. If you believe that the promise should resolve but it doesn't, and you've ruled out any logical errors in your code, then it could potentially be a bug. To determine whether it's a bug in Deno, V8, or JavaScript, you would need to provide more context and ideally a minimal reproduction case. The Deno team or the V8 team would then investigate the issue to determine the cause. If you have a reproducible example where a promise that should resolve does not, and it's not due to a logical error in the code, you might consider opening an issue in the Deno repository with all the relevant details so that the developers can look into it. 🦕

Did you find this page helpful?