Skip to content

Commit b492d9f

Browse files
committed
Address review comments
1 parent 0733fa0 commit b492d9f

File tree

45 files changed

+129
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+129
-151
lines changed

dwds/lib/src/services/chrome_proxy_service.dart

Lines changed: 47 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,9 @@ class ChromeProxyService implements VmServiceInterface {
473473
if (!_isIsolateRunning) return;
474474
final isolate = inspector.isolate;
475475

476+
final debugger = await debuggerFuture;
476477
for (final breakpoint in isolate.breakpoints?.toList() ?? <Breakpoint>[]) {
477-
await (await debuggerFuture).removeBreakpoint(breakpoint.id!);
478+
await debugger.removeBreakpoint(breakpoint.id!);
478479
}
479480
}
480481

@@ -1210,43 +1211,7 @@ class ChromeProxyService implements VmServiceInterface {
12101211
returnByValue: true,
12111212
);
12121213

1213-
if (pauseIsolatesOnStart) {
1214-
// If `pause_isolates_on_start` is enabled, pause and then the reload
1215-
// should finish later after the client removes breakpoints, reregisters
1216-
// breakpoints, and resumes.
1217-
_finishHotReloadOnResume = () async {
1218-
// Client finished setting breakpoints, called resume, and now the
1219-
// execution has resumed. Finish the hot reload so we start executing
1220-
// the new code instead.
1221-
_logger.info('Issuing \$dartHotReloadEndDwds request');
1222-
await inspector.jsEvaluate(
1223-
'\$dartHotReloadEndDwds();',
1224-
awaitPromise: true,
1225-
);
1226-
_logger.info('\$dartHotReloadEndDwds request complete.');
1227-
};
1228-
1229-
// Pause and wait for the pause to occur before managing breakpoints.
1230-
final pausedEvent = _firstStreamEvent(
1231-
'Debug',
1232-
EventKind.kPauseInterrupted,
1233-
);
1234-
await pause(isolateId);
1235-
await pausedEvent;
1236-
1237-
await _reinitializeForHotReload();
1238-
1239-
// This lets the client know that we're ready for breakpoint management
1240-
// and a resume.
1241-
_streamNotify(
1242-
'Debug',
1243-
Event(
1244-
kind: EventKind.kPausePostRequest,
1245-
timestamp: DateTime.now().millisecondsSinceEpoch,
1246-
isolate: inspector.isolateRef,
1247-
),
1248-
);
1249-
} else {
1214+
if (!pauseIsolatesOnStart) {
12501215
// Finish hot reload immediately.
12511216
_logger.info('Issuing \$dartHotReloadEndDwds request');
12521217
await inspector.jsEvaluate(
@@ -1257,7 +1222,40 @@ class ChromeProxyService implements VmServiceInterface {
12571222
// TODO(srujzs): Supposedly Dart DevTools uses a kIsolateReload event
12581223
// for breakpoints? We should confirm and add tests before sending the
12591224
// event.
1225+
return;
12601226
}
1227+
// If `pause_isolates_on_start` is enabled, pause and then the reload
1228+
// should finish later after the client removes breakpoints, reregisters
1229+
// breakpoints, and resumes.
1230+
_finishHotReloadOnResume = () async {
1231+
// Client finished setting breakpoints, called resume, and now the
1232+
// execution has resumed. Finish the hot reload so we start executing
1233+
// the new code instead.
1234+
_logger.info('Issuing \$dartHotReloadEndDwds request');
1235+
await inspector.jsEvaluate(
1236+
'\$dartHotReloadEndDwds();',
1237+
awaitPromise: true,
1238+
);
1239+
_logger.info('\$dartHotReloadEndDwds request complete.');
1240+
};
1241+
1242+
// Pause and wait for the pause to occur before managing breakpoints.
1243+
final pausedEvent = _firstStreamEvent('Debug', EventKind.kPauseInterrupted);
1244+
await pause(isolateId);
1245+
await pausedEvent;
1246+
1247+
await _reinitializeForHotReload();
1248+
1249+
// This lets the client know that we're ready for breakpoint management
1250+
// and a resume.
1251+
_streamNotify(
1252+
'Debug',
1253+
Event(
1254+
kind: EventKind.kPausePostRequest,
1255+
timestamp: DateTime.now().millisecondsSinceEpoch,
1256+
isolate: inspector.isolateRef,
1257+
),
1258+
);
12611259
}
12621260

12631261
/// Performs a WebSocket-based hot reload by sending a request and waiting for a response.
@@ -1319,37 +1317,30 @@ class ChromeProxyService implements VmServiceInterface {
13191317
String? step,
13201318
int? frameIndex,
13211319
}) async {
1322-
// If there is a hot restart or hot reload subscriber listening for a resume
1323-
// event after a hot restart or a hot reload, then add the event to the
1324-
// stream and skip processing it.
1320+
// If there is a subscriber listening for a resume event after hot-restart,
1321+
// then add the event to the stream and skip processing it.
13251322
if (_resumeAfterRestartEventsController.hasListener) {
13261323
_resumeAfterRestartEventsController.add(isolateId);
13271324
return Success();
13281325
}
1329-
Future<Success> resumeWhenAppHasStarted() {
1330-
return captureElapsedTime(() async {
1326+
1327+
if (inspector.appConnection.isStarted) {
1328+
await captureElapsedTime(() async {
13311329
await isInitialized;
13321330
await isStarted;
13331331
_checkIsolate('resume', isolateId);
1334-
return await (await debuggerFuture).resume(
1335-
step: step,
1336-
frameIndex: frameIndex,
1337-
);
1332+
final debugger = await debuggerFuture;
1333+
return await debugger.resume(step: step, frameIndex: frameIndex);
13381334
}, (result) => DwdsEvent.resume(step));
1335+
} else {
1336+
inspector.appConnection.runMain();
13391337
}
1340-
1338+
// Finish the hot reload if needed.
13411339
if (_finishHotReloadOnResume != null) {
1342-
await resumeWhenAppHasStarted();
13431340
await _finishHotReloadOnResume!();
13441341
_finishHotReloadOnResume = null;
1345-
return Success();
1346-
}
1347-
if (inspector.appConnection.isStarted) {
1348-
return resumeWhenAppHasStarted();
1349-
} else {
1350-
inspector.appConnection.runMain();
1351-
return Success();
13521342
}
1343+
return Success();
13531344
}
13541345

13551346
/// This method is deprecated in vm_service package.

dwds/test/build_daemon_callstack_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void main() {
2222

2323
group('shared context |', () {
2424
// Enable verbose logging for debugging.
25-
final debug = false;
25+
const debug = false;
2626

2727
final project = TestProject.testPackage();
2828
final context = TestContext(project, provider);

dwds/test/build_daemon_circular_evaluate_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import 'fixtures/context.dart';
1414

1515
void main() async {
1616
// Enable verbose logging for debugging.
17-
final debug = false;
17+
const debug = false;
1818

1919
final provider = TestSdkConfigurationProvider(verbose: debug);
2020
tearDownAll(provider.dispose);

dwds/test/build_daemon_evaluate_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'fixtures/context.dart';
1515

1616
void main() async {
1717
// Enable verbose logging for debugging.
18-
final debug = false;
18+
const debug = false;
1919

2020
final provider = TestSdkConfigurationProvider(verbose: debug);
2121
tearDownAll(provider.dispose);

dwds/test/build_daemon_hot_restart_correctness_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import 'fixtures/context.dart';
1616

1717
void main() {
1818
// Enable verbose logging for debugging.
19-
final debug = false;
19+
const debug = false;
2020
final canaryFeatures = false;
2121
final moduleFormat = ModuleFormat.amd;
2222
final compilationMode = CompilationMode.buildDaemon;

dwds/test/build_daemon_hot_restart_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import 'fixtures/context.dart';
1616

1717
void main() {
1818
// Enable verbose logging for debugging.
19-
final debug = false;
19+
const debug = false;
2020
final canaryFeatures = false;
2121
final moduleFormat = ModuleFormat.amd;
2222
final compilationMode = CompilationMode.buildDaemon;

dwds/test/chrome_proxy_service_amd_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import 'fixtures/context.dart';
1616

1717
void main() {
1818
// Enable verbose logging for debugging.
19-
final debug = false;
19+
const debug = false;
2020
final canaryFeatures = false;
2121
final moduleFormat = ModuleFormat.amd;
2222
final compilationMode = CompilationMode.buildDaemon;

dwds/test/chrome_proxy_service_ddc_library_bundle_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import 'fixtures/context.dart';
1616

1717
void main() {
1818
// Enable verbose logging for debugging.
19-
final debug = false;
19+
const debug = false;
2020
final canaryFeatures = true;
2121
final moduleFormat = ModuleFormat.ddc;
2222
final compilationMode = CompilationMode.frontendServer;

dwds/test/common/hot_restart_common.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ void runTests({
7777
completer.complete();
7878
}
7979
});
80-
await completer.future.then((_) {
81-
subscription.cancel();
82-
});
80+
await completer.future;
81+
await subscription.cancel();
8382
}
8483

8584
group(

dwds/test/execution_context_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
2020
import 'fixtures/fakes.dart';
2121

2222
void main() async {
23-
final debug = false;
23+
const debug = false;
2424

2525
group('ExecutionContext', () {
2626
setUpAll(() {

0 commit comments

Comments
 (0)