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