system.tag.writeBlocking doesn't block SFC onStart

I was under the impression that system.tag.writeBlocking() would block until the value(s) had been written even when writing to OPC tags.

I have an SFC step with an onStart function that sets an OPC boolean tag to true using system.tag.writeBlocking(). I thought it would not exit that step until the tag had been written.

This step is followed by a transition which looks for that same tag to be false. (an asynchronous event at a later time clears the tag to allow continuing)

However, the SFC falls right through this transition (unless there is sufficient delay after the writeBlocking like the dreaded time.sleep() ) and, if I put a counting step after the transition and loop back around to the step that sets the tag to true, I make half a dozen loops before the transition blocks on finally seeing the flag set back to true by the system.tag.writeBlocking() step right above it.

What simple thing am I missing?

EDIT: A little thought, sleep and weekend, helps. PLEASE CHECK MY WORK but I think I’ve answered my own question. Even if the tag is in an Optimistic Write tag group there is still a finite window before it gets updated that the chart can fall through the following Transition. Basically, a race condition between the thread running asynchronously to update OPC tags and the thread running the state chart.

If someone has a more elegant solution, I’d like to hear it. I’ve simply added a busy loop in my OnStart function to check that the flag reads back set. That is, the OnStart routine runs until it sees the flag set which ensures that it’s set before hitting the transition.

This seems to have the weird caveat that the tag should NOT be in an Optimistic Write tag group. If it is, the busy loop will succeed because of the Optimistic write but the transition seems to pull in the PLC tag value which hasn’t really been updated yet.