Plotly.relayout: Promise returned before drawing is done?

I’m struggling with the Plotly.relayout function where I try to connect with .then() and then draw other plots.

It seems, however, that .then() is called before the relayout is actually done. See the alert popping up in the modified example before the plot appears: https://codepen.io/c7h/pen/xxQMdvK

What am I missing here? Or how would I trigger a callback after the plot has finished?

Thanks!