Skip to content

Commit

Permalink
fix: breakpoints sometimes not being rebound after navigating away fr…
Browse files Browse the repository at this point in the history
…om and back to a page

Fixes #807
  • Loading branch information
connor4312 committed Oct 21, 2020
1 parent 55ca9c6 commit 081332b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he
- fix: exclude `nvm`-installed binaries from auto attach ([#794](https://github.com/microsoft/vscode-js-debug/issues/794))
- fix: smart auto attaching briefly debugging a process when using `code` from the CLI ([#783](https://github.com/microsoft/vscode-js-debug/issues/783))
- fix: realtime performance not being shown when a webworker is selected ([ref](https://github.com/microsoft/vscode-js-profile-visualizer/issues/23))
- fix: breakpoints sometimes not being rebound after navigating away from and back to a page ([#807](https://github.com/microsoft/vscode-js-debug/issues/807))
- refactor: remove runtime dependency on TypeScript ([ref](https://github.com/microsoft/vscode/issues/107680))

## 1.50.2 - 2020-10-02
Expand Down
10 changes: 10 additions & 0 deletions src/adapter/breakpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,4 +734,14 @@ export class BreakpointManager {
this.moduleEntryBreakpoints.set(source.path, bp);
this._setBreakpoint(bp, thread);
}

/**
* Should be called when the execution context is cleared. Breakpoints set
* on a script ID will no longer be bound correctly.
*/
public executionContextWasCleared() {
for (const bp of this.allUserBreakpoints) {
bp.executionContextWasCleared();
}
}
}
9 changes: 9 additions & 0 deletions src/adapter/breakpoints/breakpointBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,15 @@ export abstract class Breakpoint {
return uiLocations;
}

/**
* Should be called when the execution context is cleared. Breakpoints set
* on a script ID will no longer be bound correctly.
*/
public executionContextWasCleared() {
// only url-set breakpoints are still valid
this.updateCdpRefs(l => l.filter(bp => isSetByUrl(bp.args)));
}

/**
* Gets whether the breakpoint was set in the source by URL. Also checks
* the rebased remote paths, since Sources are always normalized to the
Expand Down
2 changes: 2 additions & 0 deletions src/adapter/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ export class Thread implements IVariableStoreDelegate {

_executionContextsCleared() {
this._removeAllScripts();
this._breakpointManager.executionContextWasCleared();
if (this._pausedDetails) this.onResumed();
this._executionContexts.clear();
}
Expand Down Expand Up @@ -1091,6 +1092,7 @@ export class Thread implements IVariableStoreDelegate {
const scripts = Array.from(this._sourceContainer.scriptsById.values());
this._sourceContainer.clear();
this._scriptSources.clear();
this._sourceMapLoads.clear();
Promise.all(
scripts.map(script =>
script.source.then(source => {
Expand Down

0 comments on commit 081332b

Please sign in to comment.