From 247bbc2b72090fc48cbd93b4679fa5c1eedd1a3c Mon Sep 17 00:00:00 2001 From: Jessy Yameogo Date: Wed, 25 Mar 2026 14:36:52 -0400 Subject: [PATCH 1/4] fixed injected client resolution in aot mode --- dwds/CHANGELOG.md | 4 +++- dwds/lib/src/handlers/injector.dart | 27 ++++++++++++++++++++++++++- dwds/lib/src/version.dart | 2 +- dwds/pubspec.yaml | 2 +- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index a56465df0..738af0644 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -1,4 +1,4 @@ -## 27.0.1-wip +## 27.0.1 - Replace `package:uuid` dependency with internal `Uuid` class for generating version 4 UUIDs. - Add DDC Library Bundle tests in `dwds/test/integration/instances`. - Fix WebSocket reconnection hang by ensuring Dart isolate recreation when a new browser client reuses an `AppDebugServices`. @@ -14,6 +14,8 @@ - Split additional tests across DDC module systems. - Fix issue where `DebugConnection` did not complete `onDone` if `WebkitDebugger` fails to reconnect to the debugger after the connection closes. - Fix `FormatException` in `ExtensionDebugger` by making `ExtensionEvent.fromJson` robust to missing headers and Map-typed params. +- Fix `StateError` in `DwdsInjector` by falling back to `package_config` when `Isolate.resolvePackageUri` fails in AOT mode. + ## 27.0.0 - Remove `package:built_value`, `package:built_value_generator`, and `package:built_collection` dependencies. diff --git a/dwds/lib/src/handlers/injector.dart b/dwds/lib/src/handlers/injector.dart index 610ca5b76..efa22e409 100644 --- a/dwds/lib/src/handlers/injector.dart +++ b/dwds/lib/src/handlers/injector.dart @@ -12,6 +12,7 @@ import 'package:dwds/src/config/tool_configuration.dart'; import 'package:dwds/src/loaders/ddc_library_bundle.dart'; import 'package:dwds/src/version.dart'; import 'package:logging/logging.dart'; +import 'package:package_config/package_config.dart'; import 'package:shelf/shelf.dart'; /// File extension that build_web_compilers will place the @@ -44,9 +45,33 @@ class DwdsInjector { Middleware get middleware => (innerHandler) { return (Request request) async { if (request.url.path.endsWith('$_clientScript.js')) { - final uri = await Isolate.resolvePackageUri( + var uri = await Isolate.resolvePackageUri( Uri.parse('package:$_clientScript.js'), ); + if (uri == null) { + // Fallback for AOT mode: Isolate.resolvePackageUri returns null. + // We use package_config to resolve the package path relative to the + // snapshot. + try { + if (Platform.script.scheme == 'file') { + final packageConfig = await findPackageConfig( + File(Platform.script.toFilePath()).parent, + ); + if (packageConfig != null) { + uri = packageConfig.resolve( + Uri.parse('package:$_clientScript.js'), + ); + } + } + } catch (e, s) { + _logger.warning( + 'Failed to resolve package:$_clientScript.js using' + ' package_config', + e, + s, + ); + } + } if (uri == null) { throw StateError('Cannot resolve "package:$_clientScript.js"'); } diff --git a/dwds/lib/src/version.dart b/dwds/lib/src/version.dart index a2126288c..e7766d008 100644 --- a/dwds/lib/src/version.dart +++ b/dwds/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '27.0.1-wip'; +const packageVersion = '27.0.1'; diff --git a/dwds/pubspec.yaml b/dwds/pubspec.yaml index b18971f24..be307e572 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: 27.0.1-wip +version: 27.0.1 description: >- A service that proxies between the Chrome debug protocol and the Dart VM From 530adfee6e629c67788749269fef912430f7a5e3 Mon Sep 17 00:00:00 2001 From: Jessy Yameogo Date: Wed, 25 Mar 2026 17:05:18 -0400 Subject: [PATCH 2/4] remove dart:io import --- dwds/lib/src/sockets.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dwds/lib/src/sockets.dart b/dwds/lib/src/sockets.dart index 47741dbdd..c26e0b557 100644 --- a/dwds/lib/src/sockets.dart +++ b/dwds/lib/src/sockets.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:io' show SocketException; import 'dart:typed_data'; import 'package:logging/logging.dart'; @@ -78,7 +77,7 @@ class PersistentWebSocket with StreamChannelMixin { /// re-establish a connection. /// /// No retries are attempted when making the initial web socket connection, - /// so callers must be prepared to handle both [SocketException]s and + /// so callers must be prepared to handle both `SocketException`s and /// [WebSocketException] thrown if the connection to [uri] fails. static Future connect( Uri uri, { From 10c998c41451b95d1a99ab73bba11d41c0213efa Mon Sep 17 00:00:00 2001 From: Jessy Yameogo Date: Wed, 25 Mar 2026 17:28:10 -0400 Subject: [PATCH 3/4] remove empty line --- dwds/lib/src/sockets.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/dwds/lib/src/sockets.dart b/dwds/lib/src/sockets.dart index c26e0b557..3e6968af5 100644 --- a/dwds/lib/src/sockets.dart +++ b/dwds/lib/src/sockets.dart @@ -8,7 +8,6 @@ import 'dart:typed_data'; import 'package:logging/logging.dart'; import 'package:sse/client/sse_client.dart'; import 'package:stream_channel/stream_channel.dart'; - import 'package:web_socket/web_socket.dart'; abstract class SocketClient { From beeb58cfeae2e34895d50017342c31ef52a31d44 Mon Sep 17 00:00:00 2001 From: Jessy Yameogo Date: Wed, 25 Mar 2026 19:19:05 -0400 Subject: [PATCH 4/4] restore changes to sockets.dart --- dwds/lib/src/sockets.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dwds/lib/src/sockets.dart b/dwds/lib/src/sockets.dart index 3e6968af5..47741dbdd 100644 --- a/dwds/lib/src/sockets.dart +++ b/dwds/lib/src/sockets.dart @@ -3,11 +3,13 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:io' show SocketException; import 'dart:typed_data'; import 'package:logging/logging.dart'; import 'package:sse/client/sse_client.dart'; import 'package:stream_channel/stream_channel.dart'; + import 'package:web_socket/web_socket.dart'; abstract class SocketClient { @@ -76,7 +78,7 @@ class PersistentWebSocket with StreamChannelMixin { /// re-establish a connection. /// /// No retries are attempted when making the initial web socket connection, - /// so callers must be prepared to handle both `SocketException`s and + /// so callers must be prepared to handle both [SocketException]s and /// [WebSocketException] thrown if the connection to [uri] fails. static Future connect( Uri uri, {