File tree Expand file tree Collapse file tree
packages/devtools_app/lib/src/screens/debugger Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -218,6 +218,9 @@ class CodeViewController extends DisposableController
218218 );
219219
220220 if (succeeded) {
221+ // The controller may have been disposed while awaiting the asynchronous
222+ // location display setup.
223+ if (disposed) return ;
221224 // Update the scripts history (and make sure we don't react to the
222225 // subsequent event).
223226 scriptsHistory.current.removeListener (_scriptHistoryListener);
@@ -234,6 +237,8 @@ class CodeViewController extends DisposableController
234237 final isolateRef =
235238 serviceConnection.serviceManager.isolateManager.selectedIsolate.value! ;
236239 final processedReport = await _getSourceReport (isolateRef, current.script);
240+ // The controller may have been disposed while awaiting the source report.
241+ if (disposed) return ;
237242
238243 parsedScript.value = ParsedScript (
239244 script: current.script,
@@ -264,6 +269,8 @@ class CodeViewController extends DisposableController
264269 if (scriptRef.id != parsedScript.value? .script.id) {
265270 // Try to parse the script if it isn't the currently parsed script:
266271 final script = await _parseScript (scriptRef);
272+ // The controller may have been disposed while awaiting the script parsing.
273+ if (disposed) return false ;
267274 if (script == null ) {
268275 // Return early and indicate failure if parsing fails.
269276 reportError (
You can’t perform that action at this time.
0 commit comments