Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not notify clients when we remove breakpoints before triggering a hot restart #2372

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions dwds/lib/src/debugging/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,15 @@ class Debugger extends Domain {
}

/// Remove a Dart breakpoint.
Future<Success> removeBreakpoint(String breakpointId) async {
///
/// [notifyClients] should only ever be false during a hot-restart, so that we
/// don't notify clients of the breakpoints we've removed before resuming and
/// then hot-restarting.
Future<Success> removeBreakpoint(
String breakpointId, {
notifyClients = true,
}) async {
print(StackTrace.current);
if (_breakpoints.breakpointFor(breakpointId) == null) {
throwInvalidParam(
'removeBreakpoint',
Expand All @@ -343,7 +351,7 @@ class Debugger extends Domain {
await _removeBreakpoint(jsId);

final bp = await _breakpoints.remove(jsId: jsId, dartId: breakpointId);
if (bp != null) {
if (bp != null && notifyClients) {
_streamNotify(
'Debug',
Event(
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/dwds_vm_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Future<void> _disableBreakpointsAndResume(
if (isolateId == null) {
throw StateError('No active isolate to resume.');
}
await chromeProxyService.disableBreakpoints();
await chromeProxyService.disableBreakpointsForHotRestart();
try {
// Any checks for paused status result in race conditions or hangs
// at this point:
Expand Down
8 changes: 5 additions & 3 deletions dwds/lib/src/services/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,16 @@ class ChromeProxyService implements VmServiceInterface {
_consoleSubscription = null;
}

Future<void> disableBreakpoints() async {
_disabledBreakpoints.clear();
/// This should only ever be called before a hot-restart when we are disabling
/// all breakpoints before resuming and then starting the restart.
Future<void> disableBreakpointsForHotRestart() async {
if (!_isIsolateRunning) return;
final isolate = inspector.isolate;

_disabledBreakpoints.addAll(isolate.breakpoints ?? []);
for (var breakpoint in isolate.breakpoints?.toList() ?? []) {
await (await debuggerFuture).removeBreakpoint(breakpoint.id);
await (await debuggerFuture)
.removeBreakpoint(breakpoint.id, notifyClients: false);
}
}

Expand Down
Loading