Skip to content

Commit 24121ad

Browse files
authored
Handle errors correctly when logging fails (dart-archive/appengine#148)
1 parent 05a3b34 commit 24121ad

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

pkgs/appengine/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.13.2
2+
* Gracefully handle cases where logging fails.
3+
14
## 0.13.1
25
* Fix dependency on `package:gcloud` to version `0.8.0`.
36

pkgs/appengine/lib/src/grpc_api_impl/logging_impl.dart

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,21 @@ class SharedLoggingService {
371371
..partialSuccess =
372372
false /* for now we want to get notified if something goes wrong */;
373373
_entries.clear();
374-
_clientStub.writeLogEntries(request).catchError((error, stack) {
375-
// In case the logging API failed, we'll write the error message to
376-
// stderr. The logging daemon on the VM will make another attempt at
377-
// uploading stderr via the logging API.
378-
stderr.writeln('An error occured while writing log entries:\n'
379-
'Error:$error\n'
380-
'$stack');
381-
}).whenComplete(() {
382-
_outstandingRequests--;
383-
_maybeClose();
384-
});
374+
unawaited(() async {
375+
try {
376+
await _clientStub.writeLogEntries(request);
377+
} catch (error, stack) {
378+
// In case the logging API failed, we'll write the error message to
379+
// stderr. The logging daemon on the VM will make another attempt at
380+
// uploading stderr via the logging API.
381+
stderr.writeln('An error occured while writing log entries:\n'
382+
'Error:$error\n'
383+
'$stack');
384+
} finally {
385+
_outstandingRequests--;
386+
_maybeClose();
387+
}
388+
}());
385389
}
386390

387391
Future close() {

pkgs/appengine/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: appengine
2-
version: 0.13.1
2+
version: 0.13.2
33
description: >-
44
Support for using Dart as a custom runtime on
55
Google App Engine Flexible Environment
66
homepage: https://github.com/dart-lang/appengine
77

88
environment:
9-
sdk: '>=2.12.0 <3.0.0'
9+
sdk: '>=2.14.0 <3.0.0'
1010

1111
dependencies:
1212
fixnum: ^1.0.0

0 commit comments

Comments
 (0)