Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Unified Diff: pkg/shelf/test/shelf_io_test.dart

Issue 252393007: Make sure handler errors won't bring down a shelf server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« pkg/shelf/lib/shelf_io.dart ('K') | « pkg/shelf/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/shelf/test/shelf_io_test.dart
diff --git a/pkg/shelf/test/shelf_io_test.dart b/pkg/shelf/test/shelf_io_test.dart
index 5152a697e7083b8db79e665e5c6c3b6b13e720de..67cc708c0c3e6f491fef32eca8749e765161857f 100644
--- a/pkg/shelf/test/shelf_io_test.dart
+++ b/pkg/shelf/test/shelf_io_test.dart
@@ -184,6 +184,38 @@ void main() {
expect(response.stream.bytesToString(), completion('Hello from /'));
});
});
+
+ test('passes asynchronous exceptions to the parent error zone', () {
+ return runZoned(() {
+ return shelf_io.serve((request) {
+ new Future(() => throw 'oh no');
+ return syncHandler(request);
+ }, 'localhost', 0).then((server) {
+ return http.get('http://localhost:${server.port}').then((response) {
+ expect(response.statusCode, HttpStatus.OK);
+ expect(response.body, 'Hello from /');
+ server.close();
+ });
+ });
+ }, onError: expectAsync((error) {
+ expect(error, equals('oh no'));
+ }));
+ });
+
+ test("doesn't pass asynchronous exceptions to the root error zone", () {
+ return Zone.ROOT.run(() {
+ return shelf_io.serve((request) {
+ new Future(() => throw 'oh no');
+ return syncHandler(request);
+ }, 'localhost', 0).then((server) {
+ return http.get('http://localhost:${server.port}').then((response) {
+ expect(response.statusCode, HttpStatus.OK);
+ expect(response.body, 'Hello from /');
+ server.close();
+ });
+ });
+ });
+ });
}
int _serverPort;
« pkg/shelf/lib/shelf_io.dart ('K') | « pkg/shelf/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698