From e7adc97989da6a119e05cf44016a200fca993a9a Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Mon, 29 Apr 2024 10:51:44 -0700 Subject: [PATCH] fix: executionContextCleared test flake 1. Execution contexts are cleared and we start waiting on shutdown 2. New scripts come in 3. Shutdown resolves and we incorrectly discard new scripts and context --- src/adapter/threads.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/adapter/threads.ts b/src/adapter/threads.ts index 9df79f18c..ea631da20 100644 --- a/src/adapter/threads.ts +++ b/src/adapter/threads.ts @@ -884,11 +884,18 @@ export class Thread implements IVariableStoreLocationProvider { } async _executionContextsCleared() { + const removedContexts = [...this._executionContexts.values()]; + const pausedDetails = this._pausedDetails; this._executionContexts.clear(); await this.shutdown.shutdownContext(); - this._removeAllScripts(); + for (const context of removedContexts) { + context.remove(this._sourceContainer); + } this._breakpointManager.executionContextWasCleared(); - if (this._pausedDetails) this.onResumed(); + + if (pausedDetails && pausedDetails === this._pausedDetails) { + this.onResumed(); + } } _ensureDebuggerEnabledAndRefreshDebuggerId() {