Skip to content

Conversation

@chenjiahan
Copy link
Member

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

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings January 1, 2026 02:51
@netlify
Copy link

netlify bot commented Jan 1, 2026

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit ef123b4
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/6955e34cfa77f30008e04127
😎 Deploy Preview https://deploy-preview-6878--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 72 (🟢 up 14 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a 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.

@chenjiahan chenjiahan merged commit 5289776 into main Jan 1, 2026
10 checks passed
@chenjiahan chenjiahan deleted the server_404_0101 branch January 1, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants