Skip to content

Commit 3a75266

Browse files
authored
return an error code for hot reload (#299)
* return an error code for hot reload * fix test expectation
1 parent da68a22 commit 3a75266

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

webdev/lib/src/daemon/app_domain.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ import 'utilites.dart';
2121
class AppDomain extends Domain {
2222
String _appId;
2323
AppDebugServices _appDebugServices;
24+
2425
DebugService get _debugService => _appDebugServices?.debugService;
26+
2527
VmService get _vmService => _appDebugServices?.webdevClient?.client;
2628
StreamSubscription<BuildResult> _resultSub;
2729
StreamSubscription<Event> _stdOutSub;
@@ -144,8 +146,10 @@ class AppDomain extends Domain {
144146
if (_appId != appId) throw ArgumentError.value(appId, 'appId', 'Not found');
145147
var fullRestart = getBoolArg(args, 'fullRestart') ?? false;
146148
if (!fullRestart) {
147-
throw ArgumentError.value(
148-
fullRestart, 'fullRestart', 'We do not support hot reload yet.');
149+
return {
150+
'code': 1,
151+
'message': 'hot reload not yet supported by package:flutter_web',
152+
};
149153
}
150154
// TODO(grouma) - Support pauseAfterRestart.
151155
// var pauseAfterRestart = getBoolArg(args, 'pause') ?? false;

webdev/test/daemon/app_domain_test.dart

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
@Timeout(Duration(minutes: 2))
6-
76
import 'dart:async';
87
import 'dart:convert';
98

@@ -92,6 +91,22 @@ void main() {
9291
await exitWebdev(webdev);
9392
});
9493

94+
test('.reload', () async {
95+
var webdev =
96+
await runWebDev(['daemon'], workingDirectory: exampleDirectory);
97+
var appId = await _getAppId(webdev);
98+
var extensionCall = '[{"method":"app.restart","id":0,'
99+
'"params" : { "appId" : "$appId", "fullRestart" : false}}]';
100+
webdev.stdin.add(utf8.encode('$extensionCall\n'));
101+
await expectLater(
102+
webdev.stdout,
103+
emitsThrough(startsWith(
104+
'[{"id":0,"result":{"code":1,"message":"hot reload not yet supported',
105+
)),
106+
);
107+
await exitWebdev(webdev);
108+
});
109+
95110
test('.restart', () async {
96111
var webdev =
97112
await runWebDev(['daemon'], workingDirectory: exampleDirectory);

0 commit comments

Comments
 (0)