Sorry to keep you waiting on this! We've been in the process of migrating large chunks of our visualization infrastructure to the new Kibana platform, which has meant a lot of churn in our vis APIs over
7.x releases. In fact, we've temporarily removed our vis documentation to help prevent confusion as these changes are made. All of this makes issues like these particularly hard to isolate.
Thanks for taking the time to post some example code; it was incredibly helpful in illustrating the issue you are hitting. Since you raised the problem of the uiState in a custom request handler in a separate thread, I'll focus on the issue you have brought up here, which is that calling
uiState.set followed by
uiState.get returns a
After digging into your example code, I think you've uncovered a bug that we'll need to investigate further. What is happening is that the uiState is getting set correctly, but then immediately afterwards is reset. This occurs in
visualize_embeddable.ts, specifically the
transferCustomizationsToUiState method. When that method is called with no
appState, it clears all of the keys in the uiState, triggering a change event which fires
updateInput on the embeddable.
And if that embeddable has
this.parent set, it will update the inputs for each of the children... This is why commenting out
updateInputForChild "fixes" the problem you are seeing, but of course is not a way we will be able to address this since it would break other vis embeddables.
I hope this helps explain the problem a bit... unfortunately we need to have further discussions around what the right solution should be. I've created an issue to track this in more detail if you'd like to follow along: https://github.com/elastic/kibana/issues/60162