-2

Consider this :

function some_function(){
  axios.get(...)
  .then(x=>{//handle})
  .catch(e=>{//handle})
  .then(()=>{
    setTimeout(()=>{
      some_function();
    },5000);
}

I don't care aboout cancelation, I just care if this is gonna blow the stack up.

2
  • 1
    Is there a reason you're not using await? Commented Sep 27, 2022 at 0:35
  • Not just setTimeout, also the asynchronous network request and the promise then calls prevent this from blowing up the stack. Commented Sep 27, 2022 at 0:40

1 Answer 1

1

No, it won't cause the stack to grow. setTimeout() callback functions are called from the main event loop asynchronously, not from your function. Your function returns immediately after you make the axios.get() call (since that's also asynchronous, it doesn't wait for it, either).

Sign up to request clarification or add additional context in comments.

2 Comments

I though so. But using console.trace(), traces all the way back to the first call. So that was my main concerne.
I wasn't familiar with that function. Despite what MDN says, I think that's a trace of scopes, not stack frames. Closures allow scopes to persist after popping the stack.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.