File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -694,9 +694,19 @@ class DevHandler {
694
694
readyToRunMainCompleter.future,
695
695
);
696
696
697
- // WebSocket mode: Allow connection reuse for page refreshes and same instance reconnections
697
+ // Allow connection reuse for page refreshes and same instance reconnections
698
+ final isSameInstance =
699
+ existingConnection? .request.instanceId == message.instanceId;
700
+ final isKeepAliveReconnect =
701
+ existingConnection? .isInKeepAlivePeriod == true ;
702
+ final hasNoActiveConnection = services? .connectedInstanceId == null ;
703
+ final noExistingConnection = existingConnection == null ;
704
+
698
705
final canReuseConnection =
699
- services != null && services.connectedInstanceId == null ;
706
+ services != null &&
707
+ (isSameInstance ||
708
+ (isKeepAliveReconnect && hasNoActiveConnection) ||
709
+ (noExistingConnection && hasNoActiveConnection));
700
710
701
711
if (canReuseConnection) {
702
712
// Reconnect to existing service.
Original file line number Diff line number Diff line change @@ -153,12 +153,6 @@ class WebSocketProxyService implements VmServiceInterface {
153
153
// Update app connection if override provided
154
154
appConnection = appConnectionOverride ?? appConnection;
155
155
156
- // Clean up existing isolate
157
- if (_isIsolateRunning) {
158
- destroyIsolate ();
159
- await Future .delayed (Duration (milliseconds: 10 ));
160
- }
161
-
162
156
// Auto-cleanup on connection close
163
157
await _appConnectionDoneSubscription? .cancel ();
164
158
_appConnectionDoneSubscription = appConnection.onDone.asStream ().listen ((
You can’t perform that action at this time.
0 commit comments