Don't attempt to write to stdout or stderr after stream is closed (#6)
diff --git a/CHANGELOG.md b/CHANGELOG.md index 9db945d..cc43eb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md
@@ -1,3 +1,8 @@ +#### 2.0.1 + +* Fixed bug in `ReplayProcessManager` whereby it could try to write to `stdout` + or `stderr` after the streams were closed. + #### 2.0.0 * Bumped `package:file` dependency to 2.0.1
diff --git a/lib/src/record_replay/replay_process_manager.dart b/lib/src/record_replay/replay_process_manager.dart index bef2343..6203598 100644 --- a/lib/src/record_replay/replay_process_manager.dart +++ b/lib/src/record_replay/replay_process_manager.dart
@@ -73,7 +73,7 @@ File manifestFile = fs.file(path.join(location.path, kManifestName)); if (!manifestFile.existsSync()) { throw new ArgumentError.value( - location, 'location', 'Does not represent a valid recording.'); + location, 'location', 'Does not represent a valid recording'); } String content = await manifestFile.readAsString(); @@ -288,8 +288,12 @@ // Don't flush our stdio streams until we at least reach the outer event // loop. i.e. even if `streamDelay` is zero, we still want to use the timer. new Timer(result.manager.streamDelay, () { - _stdoutController.add(_stdout); - _stderrController.add(_stderr); + if (!_stdoutController.isClosed) { + _stdoutController.add(_stdout); + } + if (!_stderrController.isClosed) { + _stderrController.add(_stderr); + } if (!daemon) kill(); }); }
diff --git a/pubspec.yaml b/pubspec.yaml index debb5a7..75e0544 100644 --- a/pubspec.yaml +++ b/pubspec.yaml
@@ -1,5 +1,5 @@ name: process -version: 2.0.0 +version: 2.0.1 authors: - Todd Volkert <tvolkert@google.com> - Michael Goderbauer <goderbauer@google.com>