简体   繁体   中英

Why async recursion shows call stack building up in the browser?

While I totally agree with the accepted answer on this SO post , I need to know if asynchronous recursion really creates a brand new call stack, why does it show the call stack building up in the browser in the following screenshot? To be fair, the call stack seems to stop growing after 32 recursions. Here's the sample code .

在此处输入图像描述

Showing async call stacks is a feature of chrome dev tools. You can switch it off with shift + ctrl + p and selecting do not capture async stack traces .

In the console output in your picture the bold text setTimeout(async) is where a new stack begins.

Async does create new stacks.

Your browser's dev tools glue those async frames together for you as a debugging convenience.

You can turn it off in the dev tools' preferences; see eg. https://developer.chrome.com/blog/new-in-devtools-60/#async-stacks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM