Description
I have a rather strange bug, that appeared after i've upgraded the version of the dart_frog to the latest 1.2.6 (although when i switch to earlier version that was working before it has the same error now, so i'm not sure what happened).
When there's a single _middleware.dart at the top route and there is a nested route inside it, middleware is being called multiple times and context.request.body() leads to the Bad state: The 'read' method can only be called once on a shelf.Request/shelf.Response object. error.
Here's the minimal repo with reproduction sample: https://github.com/SkinnyMind/middleware_error
Steps To Reproduce
- Start the dart frog server with
dart_frog dev
- Perform request with
curl -X GET http://localhost:8080/api/companies/managers/all -d "test"
- Response is
Internal Server Error
- dart_frog server prints double print message from the code (
DEBUG: ...) followed by error:
GET /api/companies/managers/all
Error thrown by handler.
Bad state: The 'read' method can only be called once on a shelf.Request/shelf.Response object.
...
Expected Behavior
No internal server error with the response containing "Success" string.
Additional Context
No response
Description
I have a rather strange bug, that appeared after i've upgraded the version of the
dart_frogto the latest 1.2.6 (although when i switch to earlier version that was working before it has the same error now, so i'm not sure what happened).When there's a single
_middleware.dartat the top route and there is a nested route inside it, middleware is being called multiple times andcontext.request.body()leads to theBad state: The 'read' method can only be called once on a shelf.Request/shelf.Response object.error.Here's the minimal repo with reproduction sample: https://github.com/SkinnyMind/middleware_error
Steps To Reproduce
dart_frog devcurl -X GET http://localhost:8080/api/companies/managers/all -d "test"Internal Server ErrorDEBUG: ...) followed by error:Expected Behavior
No internal server error with the response containing "Success" string.
Additional Context
No response