[✅ Solution] Variable value gets lost in automation?

Under which conditions does a automation variable value get lost between two automation blocks?
I have 2 execute script blocks right after each other.

Solution: It was a racing condition, as the script 1 had async calls, but it didn’t wait for them to finish.

Okay, seem to be a timing issue again :exploding_head:
Script 2 finishes before script 1.

Please convince me otherwise, but I think its wrong to have building blocks in an automation, that don’t wait for the predecessor to finish. Delay blocks don’t solve it from my perspective.

Is there no way to force script 2 to wait until script 1 is finished?

OK - thanks to my colleague I found a solution. We now made sure that all async calls in script 1 were encapsulated with await. Thus script 1 doesn’t get finished before the async functions are finished.

Lets see if this solves the issue.