Skip to content

Commit 0c1e100

Browse files
roblourensCopilot
andauthored
Chat - add null checks for editingSession across await boundaries (#309239)
Chat - add null checks for editingSession across await boundaries (#309129) awaitStatsForSession reads model.editingSession across multiple await points. If the model is disposed during one of these awaits, the editingSession property is nulled and the next access crashes. Re-check model.editingSession after each await and bail out with undefined when the session has gone away. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0c9f13b commit 0c1e100

File tree

1 file changed

+7
-0
lines changed
  • src/vs/workbench/contrib/chat/common

1 file changed

+7
-0
lines changed

src/vs/workbench/contrib/chat/common/chat.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ export async function awaitStatsForSession(model: IChatModel): Promise<IChatSess
4444
}
4545

4646
await chatEditingSessionIsReady(model.editingSession);
47+
if (!model.editingSession) {
48+
return undefined;
49+
}
50+
4751
await Promise.all(model.editingSession.entries.get().map(entry => entry.getDiffInfo?.()));
52+
if (!model.editingSession) {
53+
return undefined;
54+
}
4855

4956
const diffs = model.editingSession.entries.get();
5057
const reduceResult = diffs.reduce((acc, diff) => {

0 commit comments

Comments
 (0)