-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Console] Fix leaky mappings subscription #45646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ import 'ui/capabilities/route_setup'; | |
| /* eslint-enable @kbn/eslint/no-restricted-paths */ | ||
|
|
||
| import template from '../../public/quarantined/index.html'; | ||
| import { App } from '../../../../../core/public'; | ||
| import { App, AppUnmount } from '../../../../../core/public'; | ||
|
|
||
| export interface XPluginSet { | ||
| __LEGACY: { | ||
|
|
@@ -64,12 +64,14 @@ uiRoutes.when('/dev_tools/console', { | |
| throw new Error(message); | ||
| } | ||
|
|
||
| let unmount: AppUnmount | Promise<AppUnmount>; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you clarify for me the scenario in which unmount would be assigned a promise value?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was done to satisfy the type constraints introduced by core: https://github.com/elastic/kibana/blob/master/src/core/public/application/types.ts#L82 |
||
|
|
||
| const mockedSetupCore = { | ||
| ...npSetup.core, | ||
| application: { | ||
| register(app: App): void { | ||
| try { | ||
| app.mount(anyObject, { element: targetElement, appBasePath: '' }); | ||
| unmount = app.mount(anyObject, { element: targetElement, appBasePath: '' }); | ||
| } catch (e) { | ||
| npSetup.core.fatalErrors.add(e); | ||
| } | ||
|
|
@@ -87,6 +89,13 @@ uiRoutes.when('/dev_tools/console', { | |
| }, | ||
| }); | ||
| pluginInstance.start(npStart.core); | ||
|
|
||
| $scope.$on('$destroy', async () => { | ||
| if (unmount) { | ||
| const fn = await unmount; | ||
| fn(); | ||
| } | ||
| }); | ||
| }; | ||
| }, | ||
| template, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was running into the first of these two issues: https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild#Errors_thrown
Which indicated that cleanup for this DOM node is happening with the react component unmounting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: I re-implemented this in a more robust way.