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
aac8762a
Commit
aac8762a
authored
Mar 06, 2017
by
Todd Volkert
Committed by
GitHub
Mar 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly handle `ProcessExit` being thrown when `exit()` is called (#8592)
parent
96ccad53
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
8 deletions
+24
-8
executable.dart
packages/flutter_tools/lib/executable.dart
+18
-5
io.dart
packages/flutter_tools/lib/src/base/io.dart
+4
-2
process.dart
packages/flutter_tools/lib/src/base/process.dart
+2
-1
No files found.
packages/flutter_tools/lib/executable.dart
View file @
aac8762a
...
...
@@ -182,7 +182,12 @@ Future<int> _handleToolError(
return
_exit
(
error
.
exitCode
??
1
);
}
else
if
(
error
is
ProcessExit
)
{
// We've caught an exit code.
return
_exit
(
error
.
exitCode
);
if
(
error
.
immediate
)
{
exit
(
error
.
exitCode
);
return
error
.
exitCode
;
}
else
{
return
_exit
(
error
.
exitCode
);
}
}
else
{
// We've crashed; emit a log report.
stderr
.
writeln
();
...
...
@@ -217,7 +222,11 @@ Future<int> _handleToolError(
'Unable to generate crash report due to secondary error:
$error
\n
'
'please let us know at https://github.com/flutter/flutter/issues.'
,
);
return
_exit
(
1
);
// Any exception throw here (including one thrown by `_exit()`) will
// get caught by our zone's `onError` handler. In order to avoid an
// infinite error loop, we throw an error that is recognized above
// and will trigger an immediate exit.
throw
new
ProcessExit
(
1
,
immediate:
true
);
}
}
}
...
...
@@ -299,9 +308,13 @@ Future<int> _exit(int code) async {
// Give the task / timer queue one cycle through before we hard exit.
Timer
.
run
(()
{
printTrace
(
'exiting with code
$code
'
);
exit
(
code
);
completer
.
complete
();
try
{
printTrace
(
'exiting with code
$code
'
);
exit
(
code
);
completer
.
complete
();
}
catch
(
error
,
stackTrace
)
{
completer
.
completeError
(
error
,
stackTrace
);
}
});
await
completer
.
future
;
...
...
packages/flutter_tools/lib/src/base/io.dart
View file @
aac8762a
...
...
@@ -25,10 +25,12 @@
/// about any additional exports that you add to this file, as doing so will
/// increase the API surface that we have to test in Flutter tools, and the APIs
/// in `dart:io` can sometimes be hard to use in tests.
import
'dart:io'
as
io
show
exit
,
exitCode
;
import
'dart:io'
as
io
show
exit
;
import
'package:meta/meta.dart'
;
import
'process.dart'
;
export
'dart:io'
show
BytesBuilder
,
...
...
@@ -88,7 +90,7 @@ ExitFunction get exit => _exitFunction;
@visibleForTesting
void
setExitFunctionForTests
(
[
ExitFunction
exitFunction
])
{
_exitFunction
=
exitFunction
??
(
int
exitCode
)
{
throw
new
Exception
(
'Exited with code
${io.exitCode}
'
);
throw
new
ProcessExit
(
exitCode
,
immediate:
true
);
};
}
...
...
packages/flutter_tools/lib/src/base/process.dart
View file @
aac8762a
...
...
@@ -295,8 +295,9 @@ String _runWithLoggingSync(List<String> cmd, {
}
class
ProcessExit
implements
Exception
{
ProcessExit
(
this
.
exitCode
);
ProcessExit
(
this
.
exitCode
,
{
this
.
immediate
:
false
}
);
final
bool
immediate
;
final
int
exitCode
;
String
get
message
=>
'ProcessExit:
$exitCode
'
;
...
...
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