Skip to content

Commit 3587092

Browse files
roblourensCopilot
andcommitted
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 48409a5 commit 3587092

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • src/vs/workbench/contrib/chat/common

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)