next.js
edf903eb - Improve no response route handler error (#89036)

Commit
59 days ago
Improve no response route handler error (#89036) ## Improve route handler "no response" error message for debugging ### What? Improves the error message thrown when an app route handler doesn't return a `Response` object to include additional debugging information: - **The actual type received** - Shows whether it was `null`, `undefined`, or the constructor name for objects - **The HTTP method** - e.g., `GET`, `POST` - **The URL pathname** - The route being requested ### Why? When debugging intermittent prerender failures like: ``` Error: No response is returned from route handler '[project]/apps/web/app/favicon--route-entry.js'. ``` It was unclear what the handler actually returned. This made it difficult to diagnose whether: - The handler returned `undefined` (didn't return anything) - The handler returned `null` (explicit null) - The handler returned some other object type (module loading issue) ### How? Updated the error message format from: ``` No response is returned from route handler '/path/route.ts'. Ensure you return a `Response` or a `NextResponse` in all branches of your handler. ``` To: ``` No response is returned from route handler '/path/route.ts'. Expected a Response object but received 'undefined' (method: GET, url: /favicon.ico). Ensure you return a `Response` or a `NextResponse` in all branches of your handler. ``` ### Changes - `packages/next/src/server/route-modules/app-route/module.ts` - Enhanced error with type detection and request context - `packages/next/errors.json` - Updated error template - `test/e2e/app-dir/app-routes/app-custom-routes.test.ts` - Updated test to match new error format
Author
Parents
Loading