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"}'
  }
  returnToBTT(result);
})();

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

(async () => {
   returnToBTT('hello');
})()

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.

2 Likes

Hello,
Any update on this?

1 Like

Hello and happy new year!

The bug still seem to exist, even in alpha channel :frowning:.

Any way we can help?

Thanks!

1 Like

Sorry, took me a bit to figure out what's happening. Will be fixed with the next alpha!

1 Like

I think the issue should be fixed in 4.367 alpha! (uploading now)

Hello @Andreas_Hegenberg, happy New year and thanks for the fix!
I'm downloading it now, you previously posted a temporary workaround, should we ignore it and use the standard returnToBTT?

I'll try to test this weekend

both approaches should now work fine (hopefully)