Skip to content

Commit 4937508

Browse files
committed
updated dev_handler to throw error if proxy_service is not the right type
1 parent cf526af commit 4937508

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

dwds/lib/src/handlers/dev_handler.dart

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -559,12 +559,18 @@ class DevHandler {
559559
final appDebugServices = await loadAppServices(appConnection);
560560

561561
// Initialize WebSocket proxy service
562-
final proxyService = appDebugServices.proxyService;
563-
if (proxyService is WebSocketProxyService) {
562+
try {
563+
final proxyService = appDebugServices.proxyService;
564+
if (proxyService is! WebSocketProxyService) {
565+
throw StateError(
566+
'Expected WebSocketProxyService but got ${proxyService.runtimeType}. ',
567+
);
568+
}
564569
await proxyService.isInitialized;
565570
_logger.fine('WebSocket proxy service initialized successfully');
566-
} else {
567-
_logger.warning('WebSocket proxy service is null');
571+
} catch (e) {
572+
_logger.severe('Failed to initialize WebSocket proxy service: $e');
573+
rethrow;
568574
}
569575

570576
return DebugConnection(appDebugServices);
@@ -579,12 +585,13 @@ class DevHandler {
579585
// Initialize Chrome proxy service
580586
try {
581587
final proxyService = appDebugServices.proxyService;
582-
if (proxyService is ChromeProxyService) {
583-
await proxyService.isInitialized;
584-
_logger.fine('Chrome proxy service initialized successfully');
585-
} else {
586-
_logger.warning('Chrome proxy service is null');
588+
if (proxyService is! ChromeProxyService) {
589+
throw StateError(
590+
'Expected ChromeProxyService but got ${proxyService.runtimeType}. ',
591+
);
587592
}
593+
await proxyService.isInitialized;
594+
_logger.fine('Chrome proxy service initialized successfully');
588595
} catch (e) {
589596
_logger.severe('Failed to initialize Chrome proxy service: $e');
590597
rethrow;

dwds/lib/src/injected/client.js

Lines changed: 14 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dwds/web/reloader/manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ReloadingManager {
7878
) async {
7979
final restarter = _restarter;
8080
if (restarter is DdcLibraryBundleRestarter) {
81-
return restarter.handleServiceExtension(method, args);
81+
return await restarter.handleServiceExtension(method, args);
8282
}
8383
// For other restarter types, return null to indicate not supported
8484
return null;

0 commit comments

Comments
 (0)