Expected response.statusCode == 500, but got HttpException: Connection closed #60271
Labels
area-vm
Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
library-io
The following code simulates an error while processing a HttpRequest server side.
However this will not report a 500 on the client as expected, instead we get connection closed:
I found a workaround, which is to ensure that the
request
stream is drained before raising the exception,ie. replace the INNER TRY BLOCK with:
which will give the expected flow:
But the code feels clumsy, and I don't like that I have to drain the request stream first. Why would we waste time traversing the full stream, when we have already decided to fault.
dart info
)The text was updated successfully, but these errors were encountered: