diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index 17f414c11..8a6ba0c5a 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -1,3 +1,5 @@ +## 24.4.1-wip + ## 24.4.0 - Added support for breakpoint registering on a hot reload with the DDC library bundle format using PausePostRequests. diff --git a/dwds/lib/src/version.dart b/dwds/lib/src/version.dart index 2786a7b0a..c8bd103ab 100644 --- a/dwds/lib/src/version.dart +++ b/dwds/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '24.4.0'; +const packageVersion = '24.4.1-wip'; diff --git a/dwds/pubspec.yaml b/dwds/pubspec.yaml index f139974a6..da11ad7f1 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: 24.4.0 +version: 24.4.1-wip description: >- A service that proxies between the Chrome debug protocol and the Dart VM diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index a6a1ab373..68687d0f6 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -322,10 +322,12 @@ class TestContext { _webRunner = ResidentWebRunner( mainUri: entry, urlTunneler: debugSettings.urlEncoder, - projectDirectory: p.toUri(project.absolutePackageDirectory), + projectDirectory: Directory(project.absolutePackageDirectory).uri, packageConfigFile: project.packageConfigFile, packageUriMapper: packageUriMapper, - fileSystemRoots: [p.toUri(project.absolutePackageDirectory)], + fileSystemRoots: [ + Directory(project.absolutePackageDirectory).uri, + ], fileSystemScheme: 'org-dartlang-app', outputPath: outputDir.path, compilerOptions: compilerOptions, diff --git a/dwds/test/fixtures/project.dart b/dwds/test/fixtures/project.dart index 46bd9193b..85c921f2d 100644 --- a/dwds/test/fixtures/project.dart +++ b/dwds/test/fixtures/project.dart @@ -241,9 +241,18 @@ class TestProject { _fixturesCopy.deleteSync(recursive: true); } on FileSystemException catch (_) { // On Windows, the build daemon process might still be accessing the - // working directory, so wait a second and then try again. - await Future.delayed(const Duration(seconds: 1)); - _fixturesCopy.deleteSync(recursive: true); + // working directory, so try again with an exponential backoff. + var seconds = 1; + final maxAttempts = 3; + for (var attempt = 0; attempt < maxAttempts; attempt++) { + try { + _fixturesCopy.deleteSync(recursive: true); + break; + } on FileSystemException catch (_) { + await Future.delayed(Duration(seconds: seconds)); + seconds *= 2; + } + } } } diff --git a/frontend_server_common/lib/src/asset_server.dart b/frontend_server_common/lib/src/asset_server.dart index 095320902..f8060b661 100644 --- a/frontend_server_common/lib/src/asset_server.dart +++ b/frontend_server_common/lib/src/asset_server.dart @@ -26,6 +26,7 @@ class TestAssetServer implements AssetReader { // Fallback to "application/octet-stream" on null which // makes no claims as to the structure of the data. static const String _defaultMimeType = 'application/octet-stream'; + final Uri _projectDirectory; final FileSystem _fileSystem; final HttpServer _httpServer; final Map _files = {}; @@ -41,6 +42,7 @@ class TestAssetServer implements AssetReader { this._httpServer, this._packageUriMapper, this.internetAddress, + this._projectDirectory, this._fileSystem, this._sdkLayout, ) { @@ -65,6 +67,7 @@ class TestAssetServer implements AssetReader { /// trace. static Future start( String sdkDirectory, + Uri projectDirectory, FileSystem fileSystem, String index, String hostname, @@ -75,8 +78,8 @@ class TestAssetServer implements AssetReader { final address = (await InternetAddress.lookup(hostname)).first; final httpServer = await HttpServer.bind(address, port); final sdkLayout = TestSdkLayout.createDefault(sdkDirectory); - final server = TestAssetServer( - index, httpServer, packageUriMapper, address, fileSystem, sdkLayout); + final server = TestAssetServer(index, httpServer, packageUriMapper, address, + projectDirectory, fileSystem, sdkLayout); return server; } @@ -94,7 +97,7 @@ class TestAssetServer implements AssetReader { final headers = {}; if (request.url.path.endsWith('.html')) { - final indexFile = _fileSystem.file(index); + final indexFile = _fileSystem.file(_projectDirectory.resolve(index)); if (indexFile.existsSync()) { headers[HttpHeaders.contentTypeHeader] = 'text/html'; headers[HttpHeaders.contentLengthHeader] = @@ -244,8 +247,7 @@ class TestAssetServer implements AssetReader { // If this is a dart file, it must be on the local file system and is // likely coming from a source map request. The tool doesn't currently // consider the case of Dart files as assets. - final dartFile = - _fileSystem.file(_fileSystem.currentDirectory.uri.resolve(path)); + final dartFile = _fileSystem.file(_projectDirectory.resolve(path)); if (dartFile.existsSync()) { return dartFile; } @@ -255,7 +257,10 @@ class TestAssetServer implements AssetReader { // The file might have been a package file which is signaled by a // `/packages//` request. if (segments.first == 'packages') { - final resolved = _packageUriMapper.serverPathToResolvedUri(path); + var resolved = _packageUriMapper.serverPathToResolvedUri(path); + if (resolved != null) { + resolved = _projectDirectory.resolveUri(resolved); + } final packageFile = _fileSystem.file(resolved); if (packageFile.existsSync()) { return packageFile; @@ -311,7 +316,7 @@ class TestAssetServer implements AssetReader { } String _parseBasePathFromIndexHtml(String index) { - final file = _fileSystem.file(index); + final file = _fileSystem.file(_projectDirectory.resolve(index)); if (!file.existsSync()) { throw StateError('Index file $index is not found'); } diff --git a/frontend_server_common/lib/src/devfs.dart b/frontend_server_common/lib/src/devfs.dart index ace83aa7c..a334b832a 100644 --- a/frontend_server_common/lib/src/devfs.dart +++ b/frontend_server_common/lib/src/devfs.dart @@ -51,15 +51,11 @@ class WebDevFS { final TestSdkLayout sdkLayout; final CompilerOptions compilerOptions; - late final Directory _savedCurrentDirectory; Future create() async { - _savedCurrentDirectory = fileSystem.currentDirectory; - - fileSystem.currentDirectory = projectDirectory.toFilePath(); - assetServer = await TestAssetServer.start( sdkLayout.sdkDirectory, + projectDirectory, fileSystem, index, hostname, @@ -71,7 +67,6 @@ class WebDevFS { } Future dispose() { - fileSystem.currentDirectory = _savedCurrentDirectory; return assetServer.close(); } @@ -84,7 +79,8 @@ class WebDevFS { required bool fullRestart, }) async { final mainPath = mainUri.toFilePath(); - final outputDirectoryPath = fileSystem.file(mainPath).parent.path; + final outputDirectory = fileSystem.directory( + fileSystem.file(projectDirectory.resolve(mainPath)).parent.path); final entryPoint = mainUri.toString(); var prefix = ''; @@ -103,7 +99,10 @@ class WebDevFS { final bootstrap = '${prefix}main_module.bootstrap.js'; assetServer.writeFile( - entryPoint, fileSystem.file(mainPath).readAsStringSync()); + entryPoint, + fileSystem + .file(projectDirectory.resolve(mainPath)) + .readAsStringSync()); assetServer.writeFile(stackMapper, stackTraceMapper.readAsStringSync()); switch (ddcModuleFormat) { @@ -199,14 +198,13 @@ class WebDevFS { File metadataFile; List modules; try { - final parentDirectory = fileSystem.directory(outputDirectoryPath); codeFile = - parentDirectory.childFile('${compilerOutput.outputFilename}.sources'); + outputDirectory.childFile('${compilerOutput.outputFilename}.sources'); manifestFile = - parentDirectory.childFile('${compilerOutput.outputFilename}.json'); + outputDirectory.childFile('${compilerOutput.outputFilename}.json'); sourcemapFile = - parentDirectory.childFile('${compilerOutput.outputFilename}.map'); - metadataFile = parentDirectory + outputDirectory.childFile('${compilerOutput.outputFilename}.map'); + metadataFile = outputDirectory .childFile('${compilerOutput.outputFilename}.metadata'); modules = assetServer.write( codeFile, manifestFile, sourcemapFile, metadataFile); diff --git a/frontend_server_common/lib/src/frontend_server_client.dart b/frontend_server_common/lib/src/frontend_server_client.dart index e500646b4..3c3ae3c1d 100644 --- a/frontend_server_common/lib/src/frontend_server_client.dart +++ b/frontend_server_common/lib/src/frontend_server_client.dart @@ -402,7 +402,6 @@ class ResidentCompiler { if (compilerOptions.moduleFormat == ModuleFormat.ddc) '--dartdevc-module-format=ddc' ]; - _logger.info(args.join(' ')); final workingDirectory = projectDirectory.toFilePath(); _server = await Process.start(sdkLayout.dartAotRuntimePath, args, @@ -657,7 +656,7 @@ String _toMultiRootPath( for (final fileSystemRoot in fileSystemRoots) { final rootPath = fileSystemRoot.toFilePath(windows: Platform.isWindows); if (filePath.startsWith(rootPath)) { - return '$scheme://${filePath.substring(rootPath.length)}'; + return '$scheme:///${filePath.substring(rootPath.length)}'; } } return fileUri.toString();