Skip to content

Commit 3a5f4ef

Browse files
authored
chore(data-modeling): cleanup analysis and export on deactivate (#7616)
1 parent 0eaf66b commit 3a5f4ef

File tree

1 file changed

+12
-3
lines changed
  • packages/compass-data-modeling/src/store

1 file changed

+12
-3
lines changed

packages/compass-data-modeling/src/store/index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ export type DataModelingStoreServices = {
2727
export function activateDataModelingStore(
2828
{ openToast = _openToast }: DataModelingStoreOptions,
2929
services: DataModelingStoreServices,
30-
{ cleanup }: ActivateHelpers
30+
{ cleanup, addCleanup }: ActivateHelpers
3131
) {
32-
const cancelAnalysisControllerRef = { current: null };
33-
const cancelExportControllerRef = { current: null };
32+
const cancelAnalysisControllerRef: DataModelingExtraArgs['cancelAnalysisControllerRef'] =
33+
{ current: null };
34+
const cancelExportControllerRef: DataModelingExtraArgs['cancelExportControllerRef'] =
35+
{ current: null };
3436
const store = createStore(
3537
reducer,
3638
applyMiddleware(
@@ -42,5 +44,12 @@ export function activateDataModelingStore(
4244
})
4345
)
4446
);
47+
48+
addCleanup(() => {
49+
// Abort any ongoing analysis and exporting when deactivated.
50+
cancelAnalysisControllerRef.current?.abort();
51+
cancelExportControllerRef.current?.abort();
52+
});
53+
4554
return { store, deactivate: cleanup };
4655
}

0 commit comments

Comments
 (0)