Skip to content

Commit 6c95ac7

Browse files
committed
Fix error when closing MRVA webview during extension activation
This fixes the "Webview is disposed" error which occurs when the user closes the variant analysis webview while the extension is still activating. We will now check whether the webview is disposed before restoring the view.
1 parent 3628f4b commit 6c95ac7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

extensions/ql-vscode/src/variant-analysis/variant-analysis-view-serializer.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ export class VariantAnalysisViewSerializer implements WebviewPanelSerializer {
3737
return;
3838
}
3939

40+
// Between the time the webview is deserialized and the time the extension
41+
// is fully activated, the user may close the webview. In this case, we
42+
// should not attempt to restore the view.
43+
let disposed = false;
44+
const unregisterOnDidDispose = webviewPanel.onDidDispose(() => {
45+
disposed = true;
46+
});
47+
4048
const variantAnalysisState: VariantAnalysisState =
4149
state as VariantAnalysisState;
4250

@@ -46,18 +54,25 @@ export class VariantAnalysisViewSerializer implements WebviewPanelSerializer {
4654
variantAnalysisState.variantAnalysisId,
4755
);
4856
if (existingView) {
57+
unregisterOnDidDispose.dispose();
4958
await existingView.openView();
5059
webviewPanel.dispose();
5160
return;
5261
}
5362

63+
if (disposed) {
64+
return;
65+
}
66+
5467
const view = new VariantAnalysisView(
5568
this.ctx,
5669
this.app,
5770
variantAnalysisState.variantAnalysisId,
5871
manager,
5972
);
6073
await view.restoreView(webviewPanel);
74+
75+
unregisterOnDidDispose.dispose();
6176
}
6277

6378
private waitForExtensionFullyLoaded(): Promise<

0 commit comments

Comments
 (0)