-
-
Notifications
You must be signed in to change notification settings - Fork 246
fix(server): return a response body for 404 #6878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a Chrome browser issue where 404 responses without a response body were treated as failed navigations (ERR_HTTP_RESPONSE_CODE_FAILURE). The fix adds a plain text response body to 404 responses and refactors HTTP status codes to use an enum for better maintainability.
- Added response body "This page could not be found" to 404 responses with appropriate Content-Type header
- Introduced HttpCode enum constants (Ok, NotModified) and refactored existing code to use enum values consistently
- Reused notFoundMiddleware in hotUpdateJsonFallbackMiddleware for consistency
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/server/helper.ts | Added HttpCode.Ok and HttpCode.NotModified to the HttpCode enum |
| packages/core/src/server/middlewares.ts | Updated notFoundMiddleware to send response body with Content-Type header; replaced hardcoded status codes with HttpCode enum constants |
| packages/core/src/server/proxy.ts | Replaced hardcoded 404 with HttpCode.NotFound constant |
| packages/core/src/server/devMiddlewares.ts | Refactored hotUpdateJsonFallbackMiddleware to use notFoundMiddleware instead of inline response handling |
| packages/core/src/server/assets-middleware/middleware.ts | Replaced hardcoded status codes with HttpCode enum constants throughout; modified errorMessages type annotation to use type assertion |
| e2e/cases/environments/disable-hmr/index.test.ts | Changed test fixture from 'dev' to 'devOnly' |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Summary
This PR improves the dev server behavior when htmlFallback is set to false.
Previously, the dev server returned a 404 status without any response body. While this is technically valid, it causes Chrome to treat document navigations as failed, resulting in
ERR_HTTP_RESPONSE_CODE_FAILURE.This makes the behavior more predictable for browsers and tooling such as Playwright, especially when using the Chrome channel.
Checklist