StreamDeck Widget output being fetched by another Widget

On latest alfa 4.3.21
I created 2 simple JS widget buttons on my stream deck

(async () => {

  let result = await get_string_variable({ variable_name: 'my_var_name' })
  if (!result) {
    result = '{"text": "0", "BTTStreamDeckBackgroundColor": "100,100,100,255"}'

The other one is supposed to have a blue bg (from the apparence/default tab) and it contains this code:

(async () => {

They are both within a group.

When I open the group the second button will briefly display the blue background (not always), then switch to the bg set by the first widget (why?)

It sometimes correctly display "hello" but it will switch back and forth between "hello" and "0" that is the text set by the first button.
Sometimes it will start with 0 and switch back to "hello" and stay like this.

They both have checks "always run when widget becomes visible" and "execute script every" is set to big numbers for both (600).

So after banging my head against this for two days I've found out this problem goes away if I strip this line

my suspect is that there is a race condition.

While this part of the execution is on hold given the await, then the js engine goes ahead and run the next available function, that in this case might be the code of the second widget. That's quite normal in js land but then when it gets back to the context of the first function it propagates the result to the second one. And that's not normal.

I guess this problem seems to be related on how BTT has integrated the js engine.

In this particular case If I remove the await keyword the problems goes away

let result = get_string_variable({ variable_name: 'my_var_name' })

Ah sorry I wanted to look into this but forgot. I probably won't get to it until Monday, I'll post again once I have checked what's wrong.

1 Like

Any update on this?