Skip to content

Support hot reload over websocket #2616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 24.3.11-wip

- Added WebSocket-based hot reload support: `reloadSources` in `ChromeProxyService` and `DevHandler` now handle hot reload requests and responses over WebSockets.
- Refactored the injected client to use a reusable function for handling hot reload requests and responses over WebSockets.

## 24.3.10

- Disabled breakpoints on changed files in a hot reload. They currently do not
Expand Down
24 changes: 24 additions & 0 deletions dwds/lib/data/hot_reload_request.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library hot_reload_request;

import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

part 'hot_reload_request.g.dart';

/// A request to hot reload the application.
abstract class HotReloadRequest
implements Built<HotReloadRequest, HotReloadRequestBuilder> {
static Serializer<HotReloadRequest> get serializer =>
_$hotReloadRequestSerializer;

/// A unique identifier for this request.
String get id;

HotReloadRequest._();
factory HotReloadRequest([void Function(HotReloadRequestBuilder) updates]) =
_$HotReloadRequest;
}
151 changes: 151 additions & 0 deletions dwds/lib/data/hot_reload_request.g.dart

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

31 changes: 31 additions & 0 deletions dwds/lib/data/hot_reload_response.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library hot_reload_response;

import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

part 'hot_reload_response.g.dart';

/// A response to a hot reload request.
abstract class HotReloadResponse
implements Built<HotReloadResponse, HotReloadResponseBuilder> {
static Serializer<HotReloadResponse> get serializer =>
_$hotReloadResponseSerializer;

/// The unique identifier matching the request.
String get id;

/// Whether the hot reload succeeded on the client.
bool get success;

/// An optional error message if success is false.
@BuiltValueField(wireName: 'error')
String? get errorMessage;

HotReloadResponse._();
factory HotReloadResponse([void Function(HotReloadResponseBuilder) updates]) =
_$HotReloadResponse;
}
Loading
Loading