Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
8cac409d
Unverified
Commit
8cac409d
authored
Oct 22, 2019
by
Jonah Williams
Committed by
GitHub
Oct 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify hot restart behavior on the web (#42931)
parent
f6d3dbd6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
12 deletions
+45
-12
resident_web_runner.dart
...utter_tools/lib/src/build_runner/resident_web_runner.dart
+11
-6
resident_web_runner_test.dart
...er_tools/test/general.shard/resident_web_runner_test.dart
+34
-6
No files found.
packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
View file @
8cac409d
...
...
@@ -120,8 +120,8 @@ class ResidentWebRunner extends ResidentRunner {
return
printHelpDetails
();
}
const
String
fire
=
'🔥'
;
const
String
rawMessage
=
' To hot restart (and rebuild state), press "r" or
"R".'
;
const
String
rawMessage
=
' To hot restart changes while running, press "r". '
'To hot restart (and refresh the browser), press
"R".'
;
final
String
message
=
terminal
.
color
(
fire
+
terminal
.
bolden
(
rawMessage
),
TerminalColor
.
red
,
...
...
@@ -297,16 +297,21 @@ class ResidentWebRunner extends ResidentRunner {
final
Duration
recompileDuration
=
timer
.
elapsed
;
flutterUsage
.
sendTiming
(
'hot'
,
'web-recompile'
,
recompileDuration
);
try
{
final
vmservice
.
Response
reloadResponse
=
await
_vmService
.
callServiceExtension
(
'hotRestart'
);
printStatus
(
'Restarted application in
${getElapsedAsMilliseconds(timer.elapsed)}
.'
);
final
vmservice
.
Response
reloadResponse
=
fullRestart
?
await
_vmService
.
callServiceExtension
(
'fullReload'
)
:
await
_vmService
.
callServiceExtension
(
'hotRestart'
);
final
String
verb
=
fullRestart
?
'Restarted'
:
'Reloaded'
;
printStatus
(
'
$verb
application in
${getElapsedAsMilliseconds(timer.elapsed)}
.'
);
// Send timing analytics for full restart and for refresh.
final
bool
wasSuccessful
=
reloadResponse
.
type
==
'Success'
;
if
(!
wasSuccessful
)
{
return
OperationResult
(
1
,
reloadResponse
.
toString
());
}
flutterUsage
.
sendTiming
(
'hot'
,
'web-restart'
,
timer
.
elapsed
);
flutterUsage
.
sendTiming
(
'hot'
,
'web-refresh'
,
timer
.
elapsed
-
recompileDuration
);
if
(!
fullRestart
)
{
flutterUsage
.
sendTiming
(
'hot'
,
'web-restart'
,
timer
.
elapsed
);
flutterUsage
.
sendTiming
(
'hot'
,
'web-refresh'
,
timer
.
elapsed
-
recompileDuration
);
}
return
OperationResult
.
ok
;
}
on
vmservice
.
RPCError
{
return
OperationResult
(
1
,
'Page requires refresh.'
);
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
View file @
8cac409d
...
...
@@ -176,6 +176,7 @@ void main() {
test
(
'Can hot reload after attaching'
,
()
=>
testbed
.
run
(()
async
{
_setupMocks
();
final
BufferLogger
bufferLogger
=
logger
;
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
unawaited
(
residentWebRunner
.
run
(
connectionInfoCompleter:
connectionInfoCompleter
,
...
...
@@ -189,6 +190,7 @@ void main() {
});
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
false
);
expect
(
bufferLogger
.
statusText
,
contains
(
'Reloaded application in'
));
expect
(
result
.
code
,
0
);
// ensure that analytics are sent.
verify
(
Usage
.
instance
.
sendEvent
(
'hot'
,
'restart'
,
parameters:
<
String
,
String
>{
...
...
@@ -206,6 +208,7 @@ void main() {
test
(
'Can hot restart after attaching'
,
()
=>
testbed
.
run
(()
async
{
_setupMocks
();
final
BufferLogger
bufferLogger
=
logger
;
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
unawaited
(
residentWebRunner
.
run
(
connectionInfoCompleter:
connectionInfoCompleter
,
...
...
@@ -214,11 +217,12 @@ void main() {
when
(
mockWebFs
.
recompile
()).
thenAnswer
((
Invocation
invocation
)
async
{
return
true
;
});
when
(
mockVmService
.
callServiceExtension
(
'
hotRestart
'
)).
thenAnswer
((
Invocation
_
)
async
{
when
(
mockVmService
.
callServiceExtension
(
'
fullReload
'
)).
thenAnswer
((
Invocation
_
)
async
{
return
Response
.
parse
(<
String
,
Object
>{
'type'
:
'Success'
});
});
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
true
);
expect
(
bufferLogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
result
.
code
,
0
);
// ensure that analytics are sent.
verify
(
Usage
.
instance
.
sendEvent
(
'hot'
,
'restart'
,
parameters:
<
String
,
String
>{
...
...
@@ -227,8 +231,8 @@ void main() {
'cd29'
:
'false'
,
'cd30'
:
'true'
,
})).
called
(
1
);
verify
(
Usage
.
instance
.
sendTiming
(
'hot'
,
'web-restart'
,
any
)).
called
(
1
);
verify
(
Usage
.
instance
.
sendTiming
(
'hot'
,
'web-refresh'
,
any
)).
called
(
1
);
verify
Never
(
Usage
.
instance
.
sendTiming
(
'hot'
,
'web-restart'
,
any
)
);
verify
Never
(
Usage
.
instance
.
sendTiming
(
'hot'
,
'web-refresh'
,
any
)
);
verify
(
Usage
.
instance
.
sendTiming
(
'hot'
,
'web-recompile'
,
any
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
(),
...
...
@@ -255,7 +259,7 @@ void main() {
Usage:
()
=>
MockFlutterUsage
(),
}));
test
(
'Fails on vmservice response error'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Fails on vmservice response error
for hot restart
'
,
()
=>
testbed
.
run
(()
async
{
_setupMocks
();
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
unawaited
(
residentWebRunner
.
run
(
...
...
@@ -265,7 +269,7 @@ void main() {
when
(
mockWebFs
.
recompile
()).
thenAnswer
((
Invocation
_
)
async
{
return
true
;
});
when
(
mockVmService
.
callServiceExtension
(
'
hotRestart
'
)).
thenAnswer
((
Invocation
_
)
async
{
when
(
mockVmService
.
callServiceExtension
(
'
fullReload
'
)).
thenAnswer
((
Invocation
_
)
async
{
return
Response
.
parse
(<
String
,
Object
>{
'type'
:
'Failed'
});
});
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
true
);
...
...
@@ -279,6 +283,30 @@ void main() {
Usage:
()
=>
MockFlutterUsage
(),
}));
test
(
'Fails on vmservice response error for hot reload'
,
()
=>
testbed
.
run
(()
async
{
_setupMocks
();
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
unawaited
(
residentWebRunner
.
run
(
connectionInfoCompleter:
connectionInfoCompleter
,
));
await
connectionInfoCompleter
.
future
;
when
(
mockWebFs
.
recompile
()).
thenAnswer
((
Invocation
_
)
async
{
return
true
;
});
when
(
mockVmService
.
callServiceExtension
(
'hotRestart'
)).
thenAnswer
((
Invocation
_
)
async
{
return
Response
.
parse
(<
String
,
Object
>{
'type'
:
'Failed'
});
});
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
false
);
expect
(
result
.
code
,
1
);
expect
(
result
.
message
,
contains
(
'Failed'
));
verifyNever
(
Usage
.
instance
.
sendTiming
(
'hot'
,
'web-restart'
,
any
));
verifyNever
(
Usage
.
instance
.
sendTiming
(
'hot'
,
'web-refresh'
,
any
));
verify
(
Usage
.
instance
.
sendTiming
(
'hot'
,
'web-recompile'
,
any
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
(),
}));
test
(
'Fails on vmservice RpcError'
,
()
=>
testbed
.
run
(()
async
{
_setupMocks
();
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
...
...
@@ -290,7 +318,7 @@ void main() {
return
true
;
});
when
(
mockVmService
.
callServiceExtension
(
'hotRestart'
)).
thenThrow
(
RPCError
(
''
,
2
,
'123'
));
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
tru
e
);
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
fals
e
);
expect
(
result
.
code
,
1
);
expect
(
result
.
message
,
contains
(
'Page requires refresh'
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment