Does wixLocation.to stop code execution?

Am I correct in assume that when I use wixLocation.to() to redirect to another page on my website, all code execution on that page immediately stops?

For example, in the code below is there any danger of the session.setItem line never running?

getName().then((name) => {
  session.setItem('name', name);
});
wixLocation.to('/another-page');

Hi! Yes, you are correct that when you use wixLocation.to() to redirect to another page on your website, all code execution on the current page will immediately stop.
In the code you provided, there is a danger that the session.setItem line will never run. This is because the wixLocation.to call will redirect the user to a new page before the getName().then promise is resolved and the callback function runs. To avoid this, you can either move the wixLocation.to call inside the then callback, so that it only runs after the session.setItem call has executed, or you can use async/await to ensure that the session.setItem call runs before the redirect.