skip to Main Content
setInterval(() => {
  // do some stuff
}, 1000)

const foo = async () => {
  const res = await api_call();
  const do_stuff();
}

await foo();

Will the foo function block the setInterval when its callback is due to be executed?

2

Answers


  1. I think your question can be down to the prioritization between the callback of setInterval and foo() function under single thread

    Login or Signup to reply.
  2. If api_call returns a promise, the await function effectively ‘pauses’ the foo function until something causes the promise to resolve.

    If 1000ms pass before that happens, the timeout code executes first.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search