Open jloleysens opened 3 months ago
Pinging @elastic/kibana-core (Team:Core)
For the record:
this is where the "Kibana failed to load" message is defined:
and this is what triggers its display:
So we likely need to embed something in our initial HTML that can watch and report for these kinds of errors pre/during bootstrap time
Yeah, I think the main question here is how we want to report those.
As shown in my previous comment, those failures are happening/caught extremely early in the bootstrap process (well technically, it's even before what we call "bootstrap"), and in practice Core is not loaded yet, APM is not loaded yet, nothing is.
The two options I can think of are:
Given we do have the injected metadata in the document already, we could potentially parse them to retrieve RUM's config and manually instantiate it to send the error (what if RUM is disabled though - and do we care?).
Another option could be to perform an HTTP requests against a dedicated Kibana endpoint to show the failure in the server logs. Note, however, that it would require the endpoint to not require authentication, so we would need to be extremely careful on which information we send from the browser and log on the server (to avoid it being a perfect attack vector)
Can anyone think of any alternative?
Also FWIW, atm the whole renderTemplate
generated code is a string template, making it very tedious and error prone to modify that part of the code (no linting, no code check, no nothing). So if we were to evolve this part of our code, we should probably find a way to have it more integrated with code quality tools (moving away from string templating ideally)
3. Can anyone think of any alternative?
Push it to our telemetry endpoints? TBH, I'd rather use APM for this (it feels like a better fit for that product) but those are public unauthenticated endpoints available to us.
Yeah I like the idea of surfacing these errors in APM. I was imagining we do some kind of very simple (best effort) fetch call that can only run before bootstrap is done.
So I guess the tricky/nasty parts are:
I was imagining we do some kind of very simple (best effort) fetch call that can only run before bootstrap is done.
Oh yeah... I overlooked than APM wouldn't be loaded so that we have to manually forge the request against the right endpoint. This is even scarier...
So I guess the tricky/nasty parts are:
Yeah, your list seems accurate.
Overall, as initially mentionned, this seems like a lot of effort and complexity for questionnable gains / upsides. But if we want to do it, your approach seems the right one to me.
I was imagining we do some kind of very simple (best effort) fetch call that can only run before bootstrap is done.
Oh yeah... I overlooked than APM wouldn't be loaded so that we have to manually forge the request against the right endpoint. This is even scarier...
Should we load APM from a CDN? (the old-but-trustworthy route vs. the "new hipster" bundling strategy) 😜 https://www.elastic.co/guide/en/apm/agent/rum-js/current/install-the-agent.html#_synchronous_blocking_pattern
🙈
Kibana can fail to initialise on the client. The flow is:
bootstrap<-anonymous>.js
files (i.e. successfully contacts Kibana at origin)It's possible there are other failure scenarios. Like a failure to even load
bootstrap.js
. So we likely need to embed something in our initial HTML that can watch and report for these kinds of errors pre/during bootstrap time.Out of scope