StreamDeck Widget output being fetched by another Widget

A couple of thoughts about your widget code:

(Caveat, I'm not a heavy JS user, so this may or may not be helpful...)

I've noticed that when something goes wrong in my streamdeck widget code, I often get bleedover from an adjacent widget into the widget space that should have been rendered by the failing widget. I've found these difficult to debug, but it's usually because my code is either failing with an error or returning something that BTT can't digest.

Are you sure that the web response object in the main async function will always have a response.state attribute? Also, can it have some other value than the values you are testing for? In either case, it seems to me that retour could be undefined at the end of the function, in which case the call:

JSON.stringify(retour)

near the end of the function might fail.

Sometimes just having more load on the system is enough to trigger things that look like race conditions. (Maybe put a call to console.log(retour) just before to see what happens?)

Also, I'm unclear on whether widget code runs in an isolated context. I just recently noticed that Applescript widgets with JS code don't seem to have a checkbox for selecting global/isolated context.

If this is running in the global context, I guess it's possible that your response and retour variables are undeclared, thus global, and might be affecting the value of these variables if you are using them in other functions.