Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand All @@ -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.
Expand Down
27 changes: 26 additions & 1 deletion dwds/lib/src/handlers/injector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What packageConfig does this actually find here? I'm confused about how there could be one when this is running in AOT mode so it makes me suspect this is just finding some random packageConfig on your local machine that happens to some entry in it that works.

That could explain why this doesn't work on CI when the test runs since it is starting from a clean state.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nick's right. This method checks for .dart_tool/package_config.json in the CWD, and if it can't find it, it checks for .dart_tool/package_config.json in the parent directory. If it still can't find it, it repeats the process until we hit the root directory.

We somehow need to be able to determine the package:dwds version being used, find the PUB_CACHE, and search for the directory for the correct version of DWDS. That's unfortunately going to be brittle since an installed, precompiled webdev instance doesn't require its dependencies to still be present in the PUB_CACHE.

@dcharkes, this seems like something that should be solved by packaging client.js with webdev as part of dart install. Can you provide any guidance here? 😄

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have enough context here. DWDS is called from webdev directly?
Why are you finding the package config here? For what purpose?

I believe webdev was partially fixed to be able to work via dart install:

With dart install you cannot rely on:

  • Having access to your own source code.
  • Having access to a Dart SDK. (You can dart install something and then remove the Dart or Flutter SDK and the installed apps should keep working.)

Can you explain in more detail what dwds is trying to do here?

@dcharkes, this seems like something that should be solved by packaging client.js with webdev as part of dart install. Can you provide any guidance here? 😄

I have no idea what this means.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely right guys! My apologies. I had mistakenly assumed that globally activated packages would preserve their .dart_tool/package_config.json layout relative to the generated snapshot inside ~/.pub-cache/. I'll continue to investigate this

Copy link
Copy Markdown
Contributor

@dcharkes dcharkes Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dart data assets are not here yet:

As discussed offline with @bkonyi, until data assets are in Dart standalone, the best way to bundle a file is to just have it as a string or base64 encoded byte array.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After talking with @dcharkes, I think that #2768 is going to be the right path forward.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback guys! I will use the embedded string approach moving forward.

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"');
}
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dwds/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading