Skip to content

Commit 2707a41

Browse files
committed
fix issue with run main at start
1 parent 1fe0895 commit 2707a41

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

dwds/lib/src/services/web_socket_proxy_service.dart

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,22 @@ class WebSocketProxyService implements VmServiceInterface {
125125

126126
if (!_initializedCompleter.isCompleted) _initializedCompleter.complete();
127127

128+
// Set up appConnection.onStart listener (like Chrome flow does)
129+
appConn.onStart.then((_) {
130+
// Unlike Chrome flow, we don't have debugger.resumeFromStart(), but we can trigger resume
131+
if (pauseIsolatesOnStart && !_hasResumed) {
132+
final resumeEvent = vm_service.Event(
133+
kind: vm_service.EventKind.kResume,
134+
timestamp: DateTime.now().millisecondsSinceEpoch,
135+
isolate: isolateRef,
136+
);
137+
_hasResumed = true;
138+
_streamNotify(vm_service.EventStreams.kDebug, resumeEvent);
139+
}
140+
});
141+
128142
// Send pause event if enabled
129143
if (pauseIsolatesOnStart) {
130-
print('JY - isolate paused on start - sending pause event');
131144
final pauseEvent = vm_service.Event(
132145
kind: vm_service.EventKind.kPauseStart,
133146
timestamp: timestamp,
@@ -142,7 +155,6 @@ class WebSocketProxyService implements VmServiceInterface {
142155
// This handles the case where the app is run from terminal without debug extension
143156
_scheduleAutoResumeIfNeeded();
144157
} else {
145-
print('JY - isolate not paused on start - sending resume event');
146158
// If we're not pausing on start, immediately send a resume event
147159
// to ensure the app knows it can start running
148160
_logger.info('Not pausing on start, sending immediate resume event');
@@ -592,6 +604,11 @@ class WebSocketProxyService implements VmServiceInterface {
592604
String? step,
593605
int? frameIndex,
594606
}) async {
607+
// Check if we should trigger runMain instead
608+
if (!_hasResumed && _currentPauseEvent != null) {
609+
appConnection.runMain();
610+
}
611+
595612
// Prevent multiple resume calls
596613
if (_hasResumed && _currentPauseEvent == null) {
597614
return Success();
@@ -624,7 +641,6 @@ class WebSocketProxyService implements VmServiceInterface {
624641
/// Schedules an auto-resume if no debugger connection is detected.
625642
/// This prevents the app from being stuck in a paused state when running from terminal.
626643
void _scheduleAutoResumeIfNeeded() {
627-
print('JY - scheduling auto-resume check');
628644
_logger.info('Scheduling auto-resume check in 2 seconds');
629645
// Wait a reasonable amount of time for a debugger to connect
630646
Timer(Duration(seconds: 2), () {

0 commit comments

Comments
 (0)