@@ -64,13 +64,34 @@ All issues have been fixed and the middleware system has been optimized for bett
6464- Use ` .execute.bind(instance) ` for direct method calls
6565- Generate static middleware array when all middlewares are singletons
6666- Replaced ` ...arguments ` with explicit ` (req, res, next) ` parameters
67+ - Use pre-compiled resolvers (` injector.getResolver() ` ) for request-scoped middlewares
6768
68- ** Impact:** Significant performance improvement for applications with many singleton middlewares.
69+ ** Impact:** Significant performance improvement for applications with many middlewares.
6970
7071** Files:**
7172- ` packages/http/src/router.ts ` - Middleware optimization logic added
7273- ` packages/http/src/http.ts ` - Simplified middleware execution
7374
75+ ### 5. Improved Error Logging (DX)
76+
77+ ** Problem:** Middleware errors logged generic messages like "Could not resolve request" without context.
78+
79+ ** Solution:**
80+ - Log middleware name (class name or function name)
81+ - Include HTTP method and URL in error messages
82+ - Use named functions in generated code for better stack traces
83+
84+ ** Impact:** Much easier debugging when middleware fails.
85+
86+ ** Example output:**
87+ ```
88+ Middleware AuthMiddleware threw on GET /api/users: Invalid token
89+ ```
90+
91+ ** Files:**
92+ - ` packages/http/src/http.ts ` - Contextual error logging
93+ - ` packages/http/src/router.ts ` - Named function generation
94+
7495## Implementation Details
7596
7697### Phase 1: Bug Fixes
@@ -186,9 +207,8 @@ No performance regression for routes with minimal middleware.
186207
187208## Commits
188209
189- Key commits for this work:
190- - ` fix(http): remove broken timeout feature from middleware `
191- - ` fix(http): generic middleware errors now return 500 instead of 404 `
192- - ` feat(http): add double-next guard for middleware `
193- - ` perf(http): pre-resolve singleton middlewares at router build time `
194- - ` test(http): comprehensive middleware tests `
210+ | Hash | Description |
211+ | ------| -------------|
212+ | ` 6d6d5c28 ` | fix(http): improve middleware error handling and performance (#439 ) |
213+ | ` 3afe56b7 ` | fix(http): improve middleware error logging with context |
214+ | ` 493e2fd9 ` | perf(http): use pre-compiled resolvers for request-scoped middleware |
0 commit comments