1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix error in legacyRegisterApi on main (#5426)

This commit is contained in:
Sebastian Malton 2022-05-20 05:27:47 -07:00 committed by GitHub
parent d23f4018c8
commit acb119af94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -312,12 +312,23 @@ export interface DeleteResourceDescriptor extends ResourceDescriptor {
* @deprecated In the new extension API, don't expose `KubeApi`'s constructor
*/
function legacyRegisterApi(api: KubeApi<any, any>): void {
try {
/**
* This function throws if called in `main`, so the `try..catch` is to make sure that doesn't
* leak.
*
* However, we need this code to be run in `renderer` so that the auto registering of `KubeApi`
* instances still works. That auto registering never worked or was applicable in `main` because
* there is no "single cluster" on `main`.
*
* TODO: rearchitect this design pattern in the new extension API
*/
const di = getEnvironmentSpecificLegacyGlobalDiForExtensionApi(Environments.renderer);
if (di) {
const autoRegistrationEmitter = di.inject(autoRegistrationEmitterInjectable);
autoRegistrationEmitter.emit("kubeApi", api);
} catch {
// ignore error
}
}