creating hotfix release (#2702)
diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md
index 0fd5b5e..2b511ad 100644
--- a/dwds/CHANGELOG.md
+++ b/dwds/CHANGELOG.md
@@ -1,3 +1,6 @@
+## 25.1.0+2
+- `reloadSources` and `hotRestart` now throw an RPC error with `kServerError` code when `NoClientsAvailableException` is caught (no browser clients are connected), allowing tooling to detect and handle this scenario.
+
## 25.1.0+1
- Bump SDK constraint to ^3.10.0
diff --git a/dwds/lib/src/services/web_socket_proxy_service.dart b/dwds/lib/src/services/web_socket_proxy_service.dart
index a2400d0..c36bd53 100644
--- a/dwds/lib/src/services/web_socket_proxy_service.dart
+++ b/dwds/lib/src/services/web_socket_proxy_service.dart
@@ -33,6 +33,9 @@
/// closes before the new connection is established, preventing premature isolate destruction.
const _isolateDestructionGracePeriod = Duration(seconds: 15);
+/// Error message when no clients are available for hot reload/restart.
+const kNoClientsAvailable = 'No clients available.';
+
/// Tracks hot reload responses from multiple browser windows/tabs.
class _HotReloadTracker {
final String requestId;
@@ -117,6 +120,16 @@
}
}
+/// Exception thrown when no browser clients are connected to DWDS.
+class NoClientsAvailableException implements Exception {
+ final String message;
+
+ NoClientsAvailableException._(this.message);
+
+ @override
+ String toString() => 'NoClientsAvailableException: $message';
+}
+
/// WebSocket-based VM service proxy for web debugging.
class WebSocketProxyService extends ProxyService {
final _logger = Logger('WebSocketProxyService');
@@ -504,6 +517,14 @@
await _performWebSocketHotReload();
_logger.info('Hot reload completed successfully');
return _ReloadReportWithMetadata(success: true);
+ } on NoClientsAvailableException catch (e) {
+ // Throw RPC error with kIsolateCannotReload code when no browser clients are
+ // connected.
+ throw vm_service.RPCError(
+ 'reloadSources',
+ vm_service.RPCErrorKind.kIsolateCannotReload.code,
+ 'Hot reload failed: ${e.message}',
+ );
} catch (e) {
_logger.warning('Hot reload failed: $e');
return _ReloadReportWithMetadata(success: false, notices: [e.toString()]);
@@ -518,6 +539,14 @@
await _performWebSocketHotRestart();
_logger.info('Hot restart completed successfully');
return {'result': vm_service.Success().toJson()};
+ } on NoClientsAvailableException catch (e) {
+ // Throw RPC error with kIsolateCannotReload code when no browser clients are
+ // connected.
+ throw vm_service.RPCError(
+ 'hotRestart',
+ vm_service.RPCErrorKind.kIsolateCannotReload.code,
+ 'Hot restart failed: ${e.message}',
+ );
} catch (e) {
_logger.warning('Hot restart failed: $e');
return {
@@ -611,7 +640,8 @@
});
if (clientCount == 0) {
- throw StateError('No clients available for hot reload');
+ _logger.warning(kNoClientsAvailable);
+ throw NoClientsAvailableException._(kNoClientsAvailable);
}
// Create tracker for this hot reload request
@@ -671,7 +701,8 @@
});
if (clientCount == 0) {
- throw StateError('No clients available for hot restart');
+ _logger.warning(kNoClientsAvailable);
+ throw NoClientsAvailableException._(kNoClientsAvailable);
}
// Create tracker for this hot restart request
@@ -737,8 +768,7 @@
final request = ServiceExtensionRequest.fromArgs(
id: requestId,
method: method,
- args:
- args != null ? Map<String, dynamic>.from(args) : <String, dynamic>{},
+ args: <String, Object?>{...?args},
);
// Send the request and get the number of connected clients
diff --git a/dwds/lib/src/version.dart b/dwds/lib/src/version.dart
index e126210..2ceff74 100644
--- a/dwds/lib/src/version.dart
+++ b/dwds/lib/src/version.dart
@@ -1,2 +1,2 @@
// Generated code. Do not modify.
-const packageVersion = '25.1.0+1';
+const packageVersion = '25.1.0+2';
diff --git a/dwds/pubspec.yaml b/dwds/pubspec.yaml
index 73aca16..f488186 100644
--- a/dwds/pubspec.yaml
+++ b/dwds/pubspec.yaml
@@ -1,6 +1,6 @@
name: dwds
# Every time this changes you need to run `dart run build_runner build`.
-version: 25.1.0+1
+version: 25.1.0+2
description: >-
A service that proxies between the Chrome debug protocol and the Dart VM