Skip to content

Commit 217bfed

Browse files
jason-simmonsCommit Queue
authored andcommitted
[ DDS ] Add middleware that converts exceptions thrown by handlers into error responses
Handler functions may return a Future<Response> that completes with an error. If that happens, then the top level error handling in the Shelf server will try to log the error to stderr. But this will fail because DDS closes its stderr at startup. So Shelf will not write any response to the client, and the client will time out. This PR adds a middleware to the DDS pipeline that receives errors thrown by the pipeline's handlers and returns a failure response. Change-Id: I31beaf6abb0cbb42137c6b03f6081809de5d7119 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405681 Commit-Queue: Ben Konyi <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
1 parent 8968e0e commit 217bfed

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/dds/lib/src/dds_impl.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ class DartDevelopmentServiceImpl implements DartDevelopmentService {
188188
);
189189
}
190190
pipeline = pipeline.addMiddleware(_authCodeMiddleware);
191+
pipeline = pipeline.addMiddleware(
192+
createMiddleware(errorHandler: (Object error, StackTrace st) {
193+
return Response.internalServerError(body: error.toString());
194+
}));
191195

192196
if (_devToolsConfiguration?.enable ?? false) {
193197
// If we are enabling DevTools in DDS, then we also need to start the Dart

0 commit comments

Comments
 (0)