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:
parent
d23f4018c8
commit
acb119af94
@ -312,12 +312,23 @@ export interface DeleteResourceDescriptor extends ResourceDescriptor {
|
|||||||
* @deprecated In the new extension API, don't expose `KubeApi`'s constructor
|
* @deprecated In the new extension API, don't expose `KubeApi`'s constructor
|
||||||
*/
|
*/
|
||||||
function legacyRegisterApi(api: KubeApi<any, any>): void {
|
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);
|
const di = getEnvironmentSpecificLegacyGlobalDiForExtensionApi(Environments.renderer);
|
||||||
|
|
||||||
if (di) {
|
|
||||||
const autoRegistrationEmitter = di.inject(autoRegistrationEmitterInjectable);
|
const autoRegistrationEmitter = di.inject(autoRegistrationEmitterInjectable);
|
||||||
|
|
||||||
autoRegistrationEmitter.emit("kubeApi", api);
|
autoRegistrationEmitter.emit("kubeApi", api);
|
||||||
|
} catch {
|
||||||
|
// ignore error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user