[VM Service] Fix Windows hot reload timeout when using experimental service

Forward the `pause` parameter to the C++ runtime in reloadSources, and use
the path resolver helper to properly resolve raw Windows file paths during
hot reload compilation.

TAG=agy
CONV=ae3a29f5-e2c8-499c-b221-ff61e40f5f1f

Change-Id: Iab29cb94b390144d17f1c014ec2e9acd1ab1e11e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505160
Commit-Queue: Ben Konyi <bkonyi@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
Ben Konyi
2026-05-29 12:50:53 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 406f493bcf
commit 5b01408585
@@ -37,6 +37,7 @@ final class DartRuntimeServiceVmRpcs {
static const _kUserTags = 'userTags';
static const _kRootLibUri = 'rootLibUri';
static const _kForce = 'force';
static const _kPause = 'pause';
static const _kKernelFilePath = 'kernelFilePath';
late final rpcs = UnmodifiableListView<ServiceRpcHandler>([
@@ -154,7 +155,7 @@ final class DartRuntimeServiceVmRpcs {
final outputDill = tempDir.childFile('for_hot_reload.dill');
try {
await frontend_server.invokeCompile(
executable: Uri.parse(rootLibUri).toFilePath(),
executable: _maybeUriToFilename(rootLibUri),
outputDill: outputDill.path,
serverInfoFile: residentCompilerInfoFile,
);
@@ -171,6 +172,7 @@ final class DartRuntimeServiceVmRpcs {
_kIsolateId: isolateId,
_kKernelFilePath: outputDill.uri.toFilePath(),
_kForce: parameters[_kForce].asBoolOr(false),
_kPause: parameters[_kPause].asBoolOr(false),
},
);
} finally {
@@ -178,3 +180,18 @@ final class DartRuntimeServiceVmRpcs {
}
}
}
/// Safely converts [maybeUri] to a local file path.
///
/// Returns [maybeUri] as-is if it is already a raw path (e.g. `C:\foo.dart`
/// or `/foo.dart`) or a non-file URI. This avoids crashes on Windows where
/// drive letters (like `C:`) are mistaken for URI schemes by [Uri.parse].
String _maybeUriToFilename(String maybeUri) {
final uri = Uri.tryParse(maybeUri);
if (uri != null && (uri.scheme == 'file' || uri.scheme == '')) {
try {
return uri.toFilePath();
} catch (_) {}
}
return maybeUri;
}